Skip to content

Commit

Permalink
added github action
Browse files Browse the repository at this point in the history
  • Loading branch information
dalkia committed Jan 8, 2024
1 parent 5c44967 commit 40f8dd0
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 18,173 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/Build_LODs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build LOD

on:
workflow_dispatch:
inputs:
sceneType:
description: 'Hash or coords'
required: true
default: 'coords'
sceneDescription:
description: 'Scene description'
required: true
default: '-129,-77'
decimationRatio:
description: 'Decimation Ratio'
required: true
default: '50'

jobs:
build-and-run:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
with:
lfs: true # This ensures LFS is initialized

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'

- name: Build with dotnet
run: dotnet build --configuration Release --output ./build_output

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18.14.2'

- name: Run the application
run: .\build_output\DCL_PiXYZ.exe "${{ github.event.inputs.sceneType }}" "${{ github.event.inputs.sceneDescription }}" "${{ github.event.inputs.decimationRatio }}" "scene-lod-entities-manifest-builder/" "OutputDirectoryPath/"

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: output-artifacts
path: OutputDirectoryPath/
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
Expand Down
18 changes: 18 additions & 0 deletions DCL_PiXYZ/DCL_PiXYZ.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="PiXYZCSharpAPI" Version="2024.1.0.15-win64" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
</ItemGroup>

</Project>
46 changes: 25 additions & 21 deletions DCL_PiXYZ/PXZEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,30 @@ class PXZEntryPoint
private static PiXYZAPI pxz;
static async Task Main(string[] args)
{


if (args.Length == 0)
{
args = new string[]
{
"coords",
"-129,-77",
"100",
"../../../../scene-lod-entities-manifest-builder/",
"C:/Users/juanm/Documents/Decentraland/asset-bundle-converter/asset-bundle-converter/Assets/Resources/",
//Geneisis Plaza
//"bafkreieifr7pyaofncd6o7vdptvqgreqxxtcn3goycmiz4cnwz7yewjldq",
//"0,0",
//MonsterScene
// "bafkreifaupi2ycrpneu7danakhxvhyjewv4ixcnryu5w25oqpvcnwtjohq",
"-129,-77",
//"C:/Users/juanm/Documents/Decentraland/PiXYZ/DCL_PiXYZ/SceneRepositioner/Resources/"
"C:/Users/juanm/Documents/Decentraland/PiXYZ/scene-lod-entities-manifest-builder/",
//"-129,-77",
};
}

var paramType = args[0];
var sceneParam = args[1];
var sceneManifestDirectory = args[2];
var scenePositionJsonDirectory = Path.Combine(sceneManifestDirectory, "output-manifests");
var decimationRatio = args[2];
var sceneManifestDirectory = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), args[3]));
var scenePositionJsonDirectory = Path.Combine(sceneManifestDirectory, "output-manifests/");
var outputDirectory = args[4];

GenerateSceneManifest(sceneManifestDirectory, sceneParam);
InitializePiXYZ();
Expand All @@ -57,21 +59,20 @@ static async Task Main(string[] args)
$"{importer.GetSceneHash()}-lod-manifest.json", sceneContent, pxz);
List<PXZModel> models = await sceneRepositioner.SetupSceneInPiXYZ();

double ratio = 5;
string outputDirectory =
$"C:/Users/juanm/Documents/Decentraland/asset-bundle-converter/asset-bundle-converter/Assets/Resources/{importer.GetScenePointer()}/{ratio.ToString()}";
Directory.CreateDirectory(outputDirectory);
double ratio = double.Parse(decimationRatio);
//string finalOutputDirectory = Path.Combine(outputDirectory, $"{importer.GetScenePointer()}/{ratio.ToString()}");
string finalOutputDirectory = outputDirectory;
Directory.CreateDirectory(finalOutputDirectory);
List<IPXZModifier> modifiers = new List<IPXZModifier>();
modifiers.Add(new PXZDeleteByName(".*collider.*"));
modifiers.Add(new PXZRepairMesh(models));
modifiers.Add(new PXZDecimator(DecimateOptionsSelector.Type.RATIO, ratio));
modifiers.Add(new PXZMergeMeshes());
//modifiers.Add(new PXZDecimateAndBake());
modifiers.Add(new PXZExporter(outputDirectory, $"0_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}", ".fbx"));
modifiers.Add(new PXZExporter(finalOutputDirectory, $"0_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}", ".fbx"));

PXZStopwatch stopwatch = new PXZStopwatch();


foreach (var pxzModifier in modifiers)
{
stopwatch.Start();
Expand All @@ -83,17 +84,20 @@ static async Task Main(string[] args)

private static void GenerateSceneManifest(string sceneManifestProjectDirectory, string coords)
{
Console.WriteLine("Scene manifest directory " + sceneManifestProjectDirectory);
DoNPMInstall(sceneManifestProjectDirectory);
Console.WriteLine("Finish installation " + sceneManifestProjectDirectory);
RunNPMTool(sceneManifestProjectDirectory, coords);
Console.WriteLine("Finish building manifest " + sceneManifestProjectDirectory);
}

private static void RunNPMTool(string sceneManifestProjectDirectory, string coords)
{
// Set up the process start information
ProcessStartInfo install = new ProcessStartInfo
{
FileName = "npm", // or the full path to npm if not in PATH
Arguments = "run start --coords=" + coords, // replace with your npm command
FileName = "powershell", // or the full path to npm if not in PATH
Arguments = "npm run start --coords=" + coords, // replace with your npm command
WorkingDirectory = sceneManifestProjectDirectory,
RedirectStandardOutput = true, // if you want to read output
UseShellExecute = false,
Expand All @@ -119,14 +123,14 @@ private static void DoNPMInstall(string sceneManifestProjectDirectory)
// Set up the process start information
ProcessStartInfo install = new ProcessStartInfo
{
FileName = "npm", // or the full path to npm if not in PATH
Arguments = "i", // replace with your npm command
FileName = "powershell", // or the full path to npm if not in PATH
Arguments = "npm i", // replace with your npm command
WorkingDirectory = sceneManifestProjectDirectory,
RedirectStandardOutput = true, // if you want to read output
UseShellExecute = false,
CreateNoWindow = true
};

// Start the process
using (Process process = Process.Start(install))
{
Expand All @@ -142,8 +146,8 @@ private static void DoNPMInstall(string sceneManifestProjectDirectory)

ProcessStartInfo build = new ProcessStartInfo
{
FileName = "npm", // or the full path to npm if not in PATH
Arguments = "run build", // replace with your npm command
FileName = "powershell", // or the full path to npm if not in PATH
Arguments = "npm run build", // replace with your npm command
WorkingDirectory = sceneManifestProjectDirectory,
RedirectStandardOutput = true, // if you want to read output
UseShellExecute = false,
Expand Down Expand Up @@ -175,7 +179,7 @@ private static void InitializePiXYZ()
"204dda67aa3ea8bcb22a76bff9aa1224823b253144396405300e235e434c4711591892c19069c7");
// if no license is found, try to configure a license server
if (!pxz.Core.CheckLicense())
pxz.Core.InstallLicense("C:/Users/juanm/Documents/Decentraland/PiXYZ/pixyzsdk-29022024.lic");
pxz.Core.InstallLicense("pixyzsdk-29022024.lic");
}
}
}
2 changes: 1 addition & 1 deletion DCL_PiXYZ/SceneImporter/Importer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task<Dictionary<string,string>> DownloadAllContent()
}
catch (HttpRequestException e)
{
throw new Exception($"URL failed: {contentsURL}{sceneParam}");
throw new Exception($"URL failed: {contentsURL}{sceneParam} with error {e}");
}
}
Console.WriteLine("File Content Success!");
Expand Down
Loading

0 comments on commit 40f8dd0

Please sign in to comment.