Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added art/Deliverables/FuseeIconTop64_VS.ico
Binary file not shown.
Binary file added art/Deliverables/FuseeIconTop64_VS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dis/VSTemplate/Core/Assets/FUSEERocket.fus
Binary file not shown.
Binary file added dis/VSTemplate/Core/Assets/FuseeText.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dis/VSTemplate/Core/Assets/Lato-Black.ttf
Binary file not shown.
217 changes: 217 additions & 0 deletions dis/VSTemplate/Core/Core.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
using System.Collections.Generic;
using System.Linq;
using Fusee.Base.Common;
using Fusee.Base.Core;
using Fusee.Engine.Common;
using Fusee.Engine.Core;
using Fusee.Math.Core;
using Fusee.Serialization;
using Fusee.Xene;
using static Fusee.Engine.Core.Input;
using static Fusee.Engine.Core.Time;
using Fusee.Engine.GUI;

namespace $ext_safeprojectname$.Core
{
[FuseeApplication(Name = "FUSEE Simple Example", Description = "A very simple example.")]
public class Simple : RenderCanvas
{
// angle variables
private static float _angleHorz = M.PiOver3, _angleVert = -M.PiOver6 * 0.5f, _angleVelHorz, _angleVelVert;

private const float RotationSpeed = 7;
private const float Damping = 0.8f;

private SceneContainer _rocketScene;
private SceneRendererForward _sceneRenderer;

private const float ZNear = 1f;
private const float ZFar = 1000;
private float _fovy = M.PiOver4;

private SceneRendererForward _guiRenderer;
private SceneContainer _gui;
private SceneInteractionHandler _sih;
private readonly CanvasRenderMode _canvasRenderMode = CanvasRenderMode.SCREEN;

private bool _keys;

// Init is called on startup.
public override void Init()
{
_gui = CreateGui();
Resize(new ResizeEventArgs(Width, Height));
// Create the interaction handler
_sih = new SceneInteractionHandler(_gui);

// Set the clear color for the backbuffer to white (100% intensity in all color channels R, G, B, A).
RC.ClearColor = new float4(1, 1, 1, 1);

// Load the rocket model
_rocketScene = AssetStorage.Get<SceneContainer>("FUSEERocket.fus");

// Wrap a SceneRenderer around the model.
_sceneRenderer = new SceneRendererForward(_rocketScene);
_guiRenderer = new SceneRendererForward(_gui);
}


// RenderAFrame is called once a frame
public override void RenderAFrame()
{
// Clear the backbuffer
RC.Clear(ClearFlags.Color | ClearFlags.Depth);

// Mouse and keyboard movement
if (Keyboard.LeftRightAxis != 0 || Keyboard.UpDownAxis != 0)
{
_keys = true;
}

if (Mouse.LeftButton)
{
_keys = false;
_angleVelHorz = -RotationSpeed * Mouse.XVel * DeltaTime * 0.0005f;
_angleVelVert = -RotationSpeed * Mouse.YVel * DeltaTime * 0.0005f;
}
else if (Touch.GetTouchActive(TouchPoints.Touchpoint_0))
{
_keys = false;
var touchVel = Touch.GetVelocity(TouchPoints.Touchpoint_0);
_angleVelHorz = -RotationSpeed * touchVel.x * DeltaTime * 0.0005f;
_angleVelVert = -RotationSpeed * touchVel.y * DeltaTime * 0.0005f;
}
else
{
if (_keys)
{
_angleVelHorz = -RotationSpeed * Keyboard.LeftRightAxis * DeltaTime;
_angleVelVert = -RotationSpeed * Keyboard.UpDownAxis * DeltaTime;
}
else
{
var curDamp = (float)System.Math.Exp(-Damping * DeltaTime);
_angleVelHorz *= curDamp;
_angleVelVert *= curDamp;
}
}

_angleHorz += _angleVelHorz;
_angleVert += _angleVelVert;

// Create the camera matrix and set it as the current ModelView transformation
var mtxRot = float4x4.CreateRotationX(_angleVert) * float4x4.CreateRotationY(_angleHorz);
var mtxCam = float4x4.LookAt(0, +2, -10, 0, +2, 0, 0, 1, 0);
RC.View = mtxCam * mtxRot;

//Set the view matrix for the interaction handler.
_sih.View = RC.View;

// Constantly check for interactive objects.
if(!Mouse.Desc.Contains("Android"))
_sih.CheckForInteractiveObjects(Mouse.Position, Width, Height);

if (Touch.GetTouchActive(TouchPoints.Touchpoint_0) && !Touch.TwoPoint)
{
_sih.CheckForInteractiveObjects(Touch.GetPosition(TouchPoints.Touchpoint_0), Width, Height);
}

// Render the scene loaded in Init()
_sceneRenderer.Render(RC);
_guiRenderer.Render(RC);

// Swap buffers: Show the contents of the backbuffer (containing the currently rendered frame) on the front buffer.
Present();
}

private SceneContainer CreateGui()
{
var vsTex = AssetStorage.Get<string>("texture.vert");
var psTex = AssetStorage.Get<string>("texture.frag");

var canvasWidth = Width / 100f;
var canvasHeight = Height / 100f;

var btnFuseeLogo = new GUIButton
{
Name = "Canvas_Button"
};
btnFuseeLogo.OnMouseEnter += BtnLogoEnter;
btnFuseeLogo.OnMouseExit += BtnLogoExit;
btnFuseeLogo.OnMouseDown += BtnLogoDown;

var guiFuseeLogo = new Texture(AssetStorage.Get<ImageData>("FuseeText.png"));
var fuseeLogo = new TextureNodeContainer(
"fuseeLogo",
vsTex,
psTex,
//Set the diffuse texture you want to use.
guiFuseeLogo,
//Define anchor points. They are given in percent, seen from the lower left corner, respectively to the width/height of the parent.
//In this setup the element will stretch horizontally but stay the same vertically if the parent element is scaled.
UIElementPosition.GetAnchors(AnchorPos.TOP_TOP_LEFT),
//Define Offset and therefor the size of the element.
UIElementPosition.CalcOffsets(AnchorPos.TOP_TOP_LEFT, new float2(0, canvasHeight - 0.5f), canvasHeight, canvasWidth, new float2(1.75f, 0.5f))
);
fuseeLogo.AddComponent(btnFuseeLogo);

var fontLato = AssetStorage.Get<Font>("Lato-Black.ttf");
var guiLatoBlack = new FontMap(fontLato, 18);

var text = new TextNodeContainer(
"FUSEE Simple Example",
"ButtonText",
vsTex,
psTex,
UIElementPosition.GetAnchors(AnchorPos.STRETCH_HORIZONTAL),
UIElementPosition.CalcOffsets(AnchorPos.STRETCH_HORIZONTAL, new float2(canvasWidth / 2 - 4, 0), canvasHeight, canvasWidth, new float2(8, 1)),
guiLatoBlack,
ColorUint.Tofloat4(ColorUint.Greenery), 250f);


var canvas = new CanvasNodeContainer(
"Canvas",
_canvasRenderMode,
new MinMaxRect
{
Min = new float2(-canvasWidth / 2, -canvasHeight / 2f),
Max = new float2(canvasWidth / 2, canvasHeight / 2f)
})
{
Children = new ChildList()
{
//Simple Texture Node, contains the fusee logo.
fuseeLogo,
text
}
};

var canvasProjComp = new ProjectionComponent(ProjectionMethod.ORTHOGRAPHIC, ZNear, ZFar, _fovy);
canvas.Components.Insert(0, canvasProjComp);

return new SceneContainer
{
Children = new List<SceneNodeContainer>
{
//Add canvas.
canvas
}
};
}

public void BtnLogoEnter(CodeComponent sender)
{
_gui.Children.FindNodes(node => node.Name == "fuseeLogo").First().GetComponent<ShaderEffectComponent>().Effect.SetEffectParam("DiffuseColor", new float4(0.8f, 0.8f, 0.8f, 1f));
}

public void BtnLogoExit(CodeComponent sender)
{
_gui.Children.FindNodes(node => node.Name == "fuseeLogo").First().GetComponent<ShaderEffectComponent>().Effect.SetEffectParam("DiffuseColor", float4.One);
}

public void BtnLogoDown(CodeComponent sender)
{
OpenLink("http://fusee3d.org");
}
}
}
19 changes: 19 additions & 0 deletions dis/VSTemplate/Core/Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>$ext_safeprojectname$.Core</RootNamespace>
<PackageId>$ext_safeprojectname$.Core</PackageId>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<OutputPath>..\bin\Core</OutputPath>
</PropertyGroup>

<ItemGroup>
<Content Include="Assets\**\*" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fusee.Core" Version="0.7.6" />
</ItemGroup>
</Project>
26 changes: 26 additions & 0 deletions dis/VSTemplate/Core/Core.vstemplate
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
<TemplateData>
<Name>FUSEE Core Project</Name>
<Description>This is a template for a FUSEE core project</Description>
<ProjectType>CSharp</ProjectType>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>Core</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<LocationField>Enabled</LocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<CreateInPlace>true</CreateInPlace>
<Icon>__TemplateIcon.ico</Icon>
<PreviewImage>__PreviewImage.png</PreviewImage>
</TemplateData>
<TemplateContent>
<Project TargetFileName="Core.csproj" File="Core.csproj" ReplaceParameters="true">
<Folder Name="Assets" TargetFolderName="Assets">
<ProjectItem ReplaceParameters="false" TargetFileName="FUSEERocket.fus">FUSEERocket.fus</ProjectItem>
<ProjectItem ReplaceParameters="false" TargetFileName="FuseeText.png">FuseeText.png</ProjectItem>
<ProjectItem ReplaceParameters="false" TargetFileName="Lato-Black.ttf">Lato-Black.ttf</ProjectItem>
</Folder>
<ProjectItem ReplaceParameters="true" TargetFileName="Core.cs">Core.cs</ProjectItem>
<ProjectItem ReplaceParameters="false" TargetFileName="NuGet.config">NuGet.config</ProjectItem>
</Project>
</TemplateContent>
</VSTemplate>
5 changes: 5 additions & 0 deletions dis/VSTemplate/Core/NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<configuration>
<packageSources>
<add key="FUSEE" value="https://fuseeprojectteam.github.io/FuseeNuGetPacketRegistry/index.json" protocolVersion="3" />
</packageSources>
</configuration>
Binary file added dis/VSTemplate/Core/__PreviewImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dis/VSTemplate/Core/__TemplateIcon.ico
Binary file not shown.
66 changes: 66 additions & 0 deletions dis/VSTemplate/Desktop/Desktop.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System.IO;
using System.Runtime.InteropServices;
using Fusee.Base.Common;
using Fusee.Base.Core;
using Fusee.Base.Imp.Desktop;
using Fusee.Engine.Core;
using Fusee.Serialization;
using FileMode = Fusee.Base.Common.FileMode;
using Path = Fusee.Base.Common.Path;
using System.Reflection;
using System;

namespace $ext_safeprojectname$.Desktop
{
public class Desktop
{
public static void Main()
{
// Inject Fusee.Engine.Base InjectMe dependencies
IO.IOImp = new Fusee.Base.Imp.Desktop.IOImp();

var fap = new Fusee.Base.Imp.Desktop.FileAssetProvider("Assets");
fap.RegisterTypeHandler(
new AssetHandler
{
ReturnedType = typeof(Font),
Decoder = delegate (string id, object storage)
{
if (!Path.GetExtension(id).ToLower().Contains("ttf")) return null;
return new Font{ _fontImp = new FontImp((Stream)storage) };
},
Checker = id => Path.GetExtension(id).ToLower().Contains("ttf")
});
fap.RegisterTypeHandler(
new AssetHandler
{
ReturnedType = typeof(SceneContainer),
Decoder = delegate (string id, object storage)
{
if (!Path.GetExtension(id).ToLower().Contains("fus")) return null;
return new ConvertSceneGraph().Convert(ProtoBuf.Serializer.Deserialize<SceneContainer>((Stream)storage));
},
Checker = id => Path.GetExtension(id).ToLower().Contains("fus")
});

AssetStorage.RegisterProvider(fap);

var app = new Core.Simple();

// Inject Fusee.Engine InjectMe dependencies (hard coded)
System.Drawing.Icon appIcon = System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
app.CanvasImplementor = new Fusee.Engine.Imp.Graphics.Desktop.RenderCanvasImp(appIcon);
app.ContextImplementor = new Fusee.Engine.Imp.Graphics.Desktop.RenderContextImp(app.CanvasImplementor);
Input.AddDriverImp(new Fusee.Engine.Imp.Graphics.Desktop.RenderCanvasInputDriverImp(app.CanvasImplementor));
Input.AddDriverImp(new Fusee.Engine.Imp.Graphics.Desktop.WindowsTouchInputDriverImp(app.CanvasImplementor));
// app.InputImplementor = new Fusee.Engine.Imp.Graphics.Desktop.InputImp(app.CanvasImplementor);
// app.AudioImplementor = new Fusee.Engine.Imp.Sound.Desktop.AudioImp();
// app.NetworkImplementor = new Fusee.Engine.Imp.Network.Desktop.NetworkImp();
// app.InputDriverImplementor = new Fusee.Engine.Imp.Input.Desktop.InputDriverImp();
// app.VideoManagerImplementor = ImpFactory.CreateIVideoManagerImp();

// Start the app
app.Run();
}
}
}
28 changes: 28 additions & 0 deletions dis/VSTemplate/Desktop/Desktop.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>$ext_safeprojectname$.Desktop</RootNamespace>
<PackageId>$ext_safeprojectname$.Desktop</PackageId>
<TargetFramework>netcoreapp3.0</TargetFramework>
<OutputType>Exe</OutputType>
<DefineConstants>PLATFORM_DESKTOP</DefineConstants>
<ApplicationIcon>FuseeLogo.ico</ApplicationIcon>
</PropertyGroup>

<PropertyGroup>
<OutputPath>..\bin\Desktop</OutputPath>
</PropertyGroup>

<ItemGroup>
<Content Include="Assets\**\*" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fusee.Desktop" Version="0.7.6" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj">
<Name>Core</Name>
</ProjectReference>
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions dis/VSTemplate/Desktop/Desktop.vstemplate
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
<TemplateData>
<Name>FUSEE Desktop Project</Name>
<Description>This is a template for a FUSEE desktop project</Description>
<ProjectType>CSharp</ProjectType>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>Desktop</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<LocationField>Enabled</LocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<CreateInPlace>true</CreateInPlace>
<Icon>__TemplateIcon.ico</Icon>
<PreviewImage>__PreviewImage.png</PreviewImage>
</TemplateData>
<TemplateContent>
<Project TargetFileName="Desktop.csproj" File="Desktop.csproj" ReplaceParameters="true">
<ProjectItem ReplaceParameters="false" TargetFileName="FuseeLogo.ico">FuseeLogo.ico</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Desktop.cs">Desktop.cs</ProjectItem>
<ProjectItem ReplaceParameters="false" TargetFileName="NuGet.config">NuGet.config</ProjectItem>
</Project>
</TemplateContent>
</VSTemplate>
Binary file added dis/VSTemplate/Desktop/FuseeLogo.ico
Binary file not shown.
Loading