Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c47e766
Created dummy asset
Jonathan-Schnee Sep 28, 2021
19c288c
Merge branch 'develop' into feature/blender_addon_nla
Jonathan-Schnee Sep 28, 2021
6938915
first steps to Animations
Jonathan-Schnee Oct 6, 2021
3bd3ce3
Added some better solution for IO plugin
Jonathan-Schnee Dec 8, 2021
6488e5e
Merge branch 'feature/408-recognize-fuspath-as-asset-folder' into dev…
griestopf Dec 15, 2021
2ff50cc
added the working animation creation with comments for what does what
Jonathan-Schnee Dec 20, 2021
dcc74a1
faster animation, scale only when doapplyscale is false, animationtra…
Jonathan-Schnee Jan 27, 2022
88bf3e4
Xirkit Animations get added in the ConvAnimation and finished everyth…
Jonathan-Schnee Feb 13, 2022
db9f51c
Update FusSceneConverter.cs
Jonathan-Schnee Feb 13, 2022
a5c4c9b
Merge branch 'develop' into feature/blender_addon_nla
Jonathan-Schnee Feb 13, 2022
c742d1b
Fixed add_on because of merge (created new Proto)
Jonathan-Schnee Feb 13, 2022
3a4c5ac
Added Example
Jonathan-Schnee Feb 23, 2022
3a37b2b
Merge branch 'develop' into feature/blender_addon_nla
Jonathan-Schnee Feb 23, 2022
d6c5bb4
Linting
Jonathan-Schnee Feb 23, 2022
4474d66
Merge branch 'develop' into feature/blender_addon_nla
griestopf Apr 27, 2022
37b26be
Added BoneAnimation Blender-Exporter
Jonathan-Schnee May 28, 2022
fc08be5
Merge branch 'feature/blender_addon_nla' of https://github.com/FUSEEP…
Jonathan-Schnee May 28, 2022
7a41ce4
Working bone export and added vert and frag Shader
Jonathan-Schnee Jul 12, 2022
0a6d678
Merge branch 'develop' into feature/blender_addon_nla
Jonathan-Schnee Jul 12, 2022
7d36153
added Desktop project
Jonathan-Schnee Jul 12, 2022
c5fc1bd
First Steps with Shaders
Jonathan-Schnee Jul 30, 2022
b26ad9f
Linting
Jonathan-Schnee Jul 30, 2022
e6d6f64
Skelett-Animation now works
Jonathan-Schnee Sep 2, 2022
643426c
Merge remote-tracking branch 'origin/feature/blender_addon_nla' into …
Jonathan-Schnee Sep 11, 2022
c081d19
Linting
Jonathan-Schnee Sep 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .filenesting.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"help":"https://go.microsoft.com/fwlink/?linkid=866610"
}
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Tools/CmdLine/bin/Debug/net6.0/fusee.dll",
"args": [],
"cwd": "${workspaceFolder}/src/Tools/CmdLine",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
41 changes: 41 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/Tools/CmdLine/Fusee.Tools.CmdLine.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src/Tools/CmdLine/Fusee.Tools.CmdLine.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/src/Tools/CmdLine/Fusee.Tools.CmdLine.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
10 changes: 10 additions & 0 deletions Examples/Complete/Animation/Blazor/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
<BlazorEnableCompression>false</BlazorEnableCompression>
<BlazorCacheBootResources>false</BlazorCacheBootResources>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
<Nullable>disable</Nullable>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

<PropertyGroup>
<OutputPath>$(BaseOutputPath)\Examples\Animation\Blazor\</OutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.JSInterop.WebAssembly" Version="6.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(FuseeEngineRoot)\src\Base\Imp\Blazor\Fusee.Base.Imp.Blazor.csproj" />
<ProjectReference Include="$(FuseeEngineRoot)\src\Engine\Imp\Graphics\Blazor\Fusee.Engine.Imp.Graphics.Blazor.csproj" />
<ProjectReference Include="..\Core\Fusee.Examples.Animation.Core.csproj" />
</ItemGroup>

<ItemGroup>
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>

<Target Name="MovingAssetsToServerRoot" BeforeTargets="PostBuildEvent">
<ItemGroup>
<AssetsDir Include="$(OutputPath)$(TargetFramework)\Assets\**\*.*" />
</ItemGroup>
<Message Text="Moving 'Assets' folder to http server root folder" Importance="high" />
<Move SourceFiles="@(AssetsDir)" DestinationFolder="$(OutputPath)$(TargetFramework)\wwwroot\Assets\%(RecursiveDir)" />
<RemoveDir Directories="$(OutputPath)$(TargetFramework)\Assets" />
</Target>

</Project>
231 changes: 231 additions & 0 deletions Examples/Complete/Animation/Blazor/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
using Fusee.Base.Common;
using Fusee.Base.Core;
using Fusee.Base.Imp.Blazor;
using Fusee.Engine.Core;
using Fusee.Engine.Core.Scene;
using Fusee.Engine.Imp.Graphics.Blazor;
using Fusee.Serialization;
using Microsoft.JSInterop;
using ProtoBuf;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Path = System.IO.Path;
using Stream = System.IO.Stream;

namespace Fusee.Examples.Simple.Blazor
{
public class Main : BlazorBase
{
private RenderCanvasImp _canvasImp;
private Core.Animation _app;

public override void Run()
{
Console.WriteLine("Starting Blazor program");

// Disable colored console ouput, not supported
Diagnostics.UseConsoleColor(false);
Diagnostics.SetMinDebugOutputLoggingSeverityLevel(Diagnostics.SeverityLevel.Verbose);

base.Run();

// Inject Fusee.Engine.Base InjectMe dependencies
Base.Core.IO.IOImp = new Fusee.Base.Imp.Blazor.IO();

#region FAP

var fap = new Fusee.Base.Imp.Blazor.AssetProvider(Runtime);
fap.RegisterTypeHandler(
new AssetHandler
{
ReturnedType = typeof(Base.Core.Font),
Decoder = (_, __) => throw new System.NotImplementedException("Non-async decoder isn't supported in Blazor builds"),
DecoderAsync = async (string id, object storage) =>
{
if (Path.GetExtension(id).Contains("ttf", System.StringComparison.OrdinalIgnoreCase))
{
var font = new Base.Core.Font
{
_fontImp = new FontImp((Stream)storage)
};

return await Task.FromResult(font);
}

return null;
},
Checker = (string id) =>
{
return Path.GetExtension(id).Contains("ttf", System.StringComparison.OrdinalIgnoreCase);
}
});

fap.RegisterTypeHandler(
new AssetHandler
{
ReturnedType = typeof(SceneContainer),
Decoder = (_, __) => throw new System.NotImplementedException("Non-async decoder isn't supported in Blazor builds"),
DecoderAsync = async (string id, object storage) =>
{
if (Path.GetExtension(id).IndexOf("fus", System.StringComparison.OrdinalIgnoreCase) >= 0)
{
return await FusSceneConverter.ConvertFromAsync(Serializer.Deserialize<FusFile>((System.IO.Stream)storage));
}
return null;
},
Checker = (string id) =>
{
return Path.GetExtension(id).Contains("fus", System.StringComparison.OrdinalIgnoreCase);
}
});

// Image handler
fap.RegisterTypeHandler(new AssetHandler
{
ReturnedType = typeof(Base.Core.ImageData),
Decoder = (_, __) => throw new NotImplementedException("Non-async decoder isn't supported in Blazor builds"),
DecoderAsync = async (string id, object storage) =>
{
var ext = Path.GetExtension(id).ToLower();

try
{
//using var ms = new MemoryStream();
//((Stream)storage).CopyTo(ms);
using var image = await Image.LoadAsync((Stream)storage);

image.Mutate(x => x.AutoOrient());
image.Mutate(x => x.RotateFlip(RotateMode.None, FlipMode.Vertical));
var ret = ReadPixels(image);

return ret;

// inner method to prevent Span<T> inside async method error
static ImageData ReadPixels(Image image)
{
var bpp = image.PixelType.BitsPerPixel;

switch (image.PixelType.BitsPerPixel)
{
case 16:
{
(image as Image<Rg32>).TryGetSinglePixelSpan(out var res);
var resBytes = MemoryMarshal.AsBytes<Rg32>(res.ToArray());
return new ImageData(resBytes.ToArray(), image.Width, image.Height,
new ImagePixelFormat(ColorFormat.Depth16));
}
case 24:
{
var rgb = image as Image<Rgb24>;

rgb.TryGetSinglePixelSpan(out var res);
var resBytes = MemoryMarshal.AsBytes<Rgb24>(res.ToArray());
return new ImageData(resBytes.ToArray(), image.Width, image.Height,
new ImagePixelFormat(ColorFormat.RGB));
}
case 32:
{
var rgba = image as Image<Rgba32>;

rgba.TryGetSinglePixelSpan(out var res);
var resBytes = MemoryMarshal.AsBytes<Rgba32>(res.ToArray());
return new ImageData(resBytes.ToArray(), image.Width, image.Height,
new ImagePixelFormat(ColorFormat.RGBA));
}
case 48:
{
var rgba = image as Image<Rgba32>;

rgba.TryGetSinglePixelSpan(out var res);
var resBytes = MemoryMarshal.AsBytes<Rgba32>(res.ToArray());
return new ImageData(resBytes.ToArray(), image.Width, image.Height,
new ImagePixelFormat(ColorFormat.fRGB32));
}
case 64:
{
(image as Image<Rgba64>).TryGetSinglePixelSpan(out var res);
var resBytes = MemoryMarshal.AsBytes<Rgba64>(res.ToArray());
return new ImageData(resBytes.ToArray(), image.Width, image.Height,
new ImagePixelFormat(ColorFormat.fRGBA32));
}
default:
{
Console.WriteLine($"Error converting! {bpp}");

throw new ArgumentException($"{bpp} Bits per pixel not supported!");

}
}
};
}
catch (Exception ex)
{
Console.WriteLine($"Error loading/converting image {id} {ex}");
Diagnostics.Error($"Error loading/converting image {id}", ex);

// return empty 1x1 image
return new ImageData(new byte[] { 0, 0, 0, 1, 0, 0, 0, 1 }, 1, 1,
new ImagePixelFormat(ColorFormat.RGBA));

}

},
Checker = (string id) =>
{
var ext = Path.GetExtension(id).ToLower();
return true;
}
});

AssetStorage.RegisterProvider(fap);

#endregion

_app = new Core.Simple();

// Inject Fusee.Engine InjectMe dependencies (hard coded)
_canvasImp = new RenderCanvasImp(canvas, Runtime, gl, canvasWidth, canvasHeight);
_app.CanvasImplementor = _canvasImp;
_app.ContextImplementor = new RenderContextImp(_app.CanvasImplementor);
Input.AddDriverImp(new RenderCanvasInputDriverImp(_app.CanvasImplementor, Runtime));

_app.LoadingCompleted += (s, e) =>
{
Console.WriteLine("Loading finished");
((IJSInProcessRuntime)Runtime).InvokeVoid("LoadingFinished");
};

_app.InitApp();

// Start the app
_app.Run();
}

public override void Update(double elapsedMilliseconds)
{
if (_canvasImp != null)
_canvasImp.DeltaTimeUpdate = (float)(elapsedMilliseconds / 1000.0);

_canvasImp?.DoUpdate();
}

public override void Draw(double elapsedMilliseconds)
{
if (_canvasImp != null)
_canvasImp.DeltaTime = (float)(elapsedMilliseconds / 1000.0);

_canvasImp?.DoRender();
}

public override void Resize(int width, int height)
{
base.Resize(width, height);
_canvasImp?.DoResize(width, height);
}
}
}
23 changes: 23 additions & 0 deletions Examples/Complete/Animation/Blazor/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@page "/"
@using System.Runtime.CompilerServices
@using System.Diagnostics.CodeAnalysis
@inject IJSRuntime JS


@code
{

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
var program = new Fusee.Base.Imp.Blazor.BlazorProgramm();
var main = new Main();
program.Start(main, (IJSInProcessRuntime)JS);
}



await base.OnAfterRenderAsync(firstRender);
}
}
Loading