Holidays 12.10. -> 25.10.2020

~ Moved code around in files.

SM.Base:
+ PostProcessing-system
+ OnInitialization() for Scenes.
+ Shader-Extensions
+ Added option to not react while unfocused to the window.
+ Added Screenshots to the window.
+ Connected the log system to the SM.OGL-action system.

~ Replaced IShader with abstract MaterialShader.
~ When a log compression folder doesn't exist, it will create one.

SM.OGL:
+ Added support for UniformArrays
+ Added ShaderPreProcessing
+ Added Shader Extensions.
+ Added Debug actions.
+ SM.OGL settings

~ Framebuffer Size is automaticly changed, when the window and scale is set.

SM2D:
+ Added easy shader drawing.
This commit is contained in:
Michel Fedde 2020-10-24 15:10:36 +02:00
parent 2c00dbd31a
commit 03b3942732
102 changed files with 2683 additions and 1398 deletions

View file

@ -1,21 +1,28 @@
using OpenTK;
#region usings
using OpenTK;
using OpenTK.Input;
using SM.Base;
using SM.Base.Controls;
using SM2D.Scene;
#endregion
namespace SM2D.Controls
{
public class Mouse2D : Mouse<GLWindow2D>
{
protected internal Mouse2D(GLWindow2D window) : base(window)
{ }
{
}
internal new void MouseMoveEvent(MouseMoveEventArgs mmea) => base.MouseMoveEvent(mmea);
internal new void MouseMoveEvent(MouseMoveEventArgs mmea)
{
base.MouseMoveEvent(mmea);
}
public Vector2 InWorld()
{
Vector2 res = _window.WorldScale;
var res = _window.WorldScale;
return InScreenNormalized * res - res / 2;
}

View file

@ -1,15 +1,16 @@
using System.Collections.Generic;
#region usings
using System.Collections.Generic;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using SM.Base;
using SM.Base.Contexts;
using SM.Base.Objects.Static;
using SM.Base.Scene;
using SM.Base.Textures;
using SM.OGL.Texture;
using SM2D.Shader;
using SM2D.Types;
#endregion
namespace SM2D.Drawing
{
@ -17,6 +18,22 @@ namespace SM2D.Drawing
{
private Material _material = new Material();
public DrawBackground(Color4 color)
{
Color = color;
}
public DrawBackground(Bitmap texture)
{
Texture = (Texture) texture;
}
public DrawBackground(Bitmap texture, Color4 tint)
{
Color = tint;
Texture = (Texture) texture;
}
public Color4 Color
{
get => _material.Tint;
@ -28,28 +45,14 @@ namespace SM2D.Drawing
get => _material.Texture;
set => _material.Texture = value;
}
public DrawBackground(Color4 color)
{
Color = color;
}
public DrawBackground(Bitmap texture)
{
Texture = (Texture)texture;
}
public DrawBackground(Bitmap texture, Color4 tint)
{
Color = tint;
Texture = (Texture) texture;
}
public object Parent { get; set; }
public string Name { get; set; } = "Background";
public ICollection<string> Flags { get; set; } = new string[0];
public void Update(UpdateContext context)
{ }
{
}
public void Draw(DrawContext context)
{

View file

@ -0,0 +1,19 @@
using SM.Base.Contexts;
using SM.Base.Scene;
using SM2D.Scene;
namespace SM2D.Drawing
{
public class DrawBackgroundShader : DrawShader, IBackgroundItem
{
public DrawBackgroundShader(MaterialShader shader) : base(shader)
{ }
protected override void DrawContext(ref DrawContext context)
{
Transform.Size.Set(context.WorldScale);
base.DrawContext(ref context);
}
}
}

View file

@ -1,14 +1,26 @@
using OpenTK.Graphics;
using SM.Base;
#region usings
using OpenTK.Graphics;
using SM.Base.Contexts;
using SM.Base.Scene;
using SM2D.Scene;
using SM2D.Types;
#endregion
namespace SM2D.Drawing
{
public class DrawColor : DrawingBasis<Transformation>, I2DShowItem
{
public DrawColor()
{
}
public DrawColor(Color4 color)
{
_material.Tint = color;
}
public Color4 Color
{
get => _material.Tint;
@ -17,13 +29,6 @@ namespace SM2D.Drawing
public int ZIndex { get; set; }
public DrawColor() {}
public DrawColor(Color4 color)
{
_material.Tint = color;
}
protected override void DrawContext(ref DrawContext context)
{
context.Instances[0].ModelMatrix = Transform.GetMatrix();

View file

@ -1,15 +1,17 @@
using SM.Base.Contexts;
#region usings
using SM.Base.Contexts;
using SM.Base.Scene;
using SM.OGL.Mesh;
using SM2D.Scene;
using SM2D.Types;
#endregion
namespace SM2D.Drawing
{
public class DrawComplex: DrawingBasis<Transformation>, I2DShowItem
public class DrawComplex : DrawingBasis<Transformation>, I2DShowItem
{
public int ZIndex { get; set; }
public Material Material
{
get => _material;
@ -22,6 +24,8 @@ namespace SM2D.Drawing
set => _mesh = value;
}
public int ZIndex { get; set; }
protected override void DrawContext(ref DrawContext context)
{
context.Instances[0].ModelMatrix = Transform.GetMatrix();

View file

@ -1,38 +1,46 @@
using System.Drawing;
#region usings
using System.Drawing;
using OpenTK.Graphics;
using SM.Base.Textures;
using SM.OGL.Texture;
using SM2D.Object;
#endregion
namespace SM2D.Drawing
{
public class DrawPolygon : DrawColor
{
public Polygon Polygon
public DrawPolygon(Polygon polygon) : this(polygon, Color4.White)
{
get => (Polygon)_mesh;
set => _mesh = value;
}
public Texture Texture
public DrawPolygon(Polygon polygon, Bitmap map) : this(polygon, map, Color4.White)
{
get => (Texture)_material.Texture;
set => _material.Texture = value;
}
public DrawPolygon(Polygon polygon) {}
public DrawPolygon(Polygon polygon, Bitmap map) : this(polygon, map, Color4.White) {}
public DrawPolygon(Polygon polygon, Color4 color) : base(color)
{
_mesh = polygon;
}
public DrawPolygon(Polygon polygon, Bitmap map, Color4 tint) : base(tint)
{
_mesh = polygon;
_material.Texture = new Texture(map);
}
public Polygon Polygon
{
get => (Polygon) _mesh;
set => _mesh = value;
}
public Texture Texture
{
get => (Texture) _material.Texture;
set => _material.Texture = value;
}
}
}

View file

@ -0,0 +1,24 @@
using SM.Base.Contexts;
using SM.Base.Scene;
using SM2D.Scene;
using SM2D.Types;
namespace SM2D.Drawing
{
public class DrawShader : DrawingBasis<Transformation>, I2DShowItem
{
public int ZIndex { get; set; }
public DrawShader(MaterialShader shader)
{
_material.CustomShader = shader;
}
protected override void DrawContext(ref DrawContext context)
{
context.Instances[0].ModelMatrix = Transform.GetMatrix();
_material.CustomShader.Draw(context);
}
}
}

View file

@ -1,10 +1,13 @@
using SM.Base;
#region usings
using SM.Base.Contexts;
using SM.Base.Text;
using SM.Base.Types;
using SM2D.Scene;
using SM2D.Types;
#endregion
namespace SM2D.Drawing
{
public class DrawText : TextDrawingBasis<Transformation>, I2DShowItem
@ -15,6 +18,8 @@ namespace SM2D.Drawing
Transform.Size = new CVector2(1);
}
public int ZIndex { get; set; }
protected override void DrawContext(ref DrawContext context)
{
base.DrawContext(ref context);
@ -24,7 +29,5 @@ namespace SM2D.Drawing
context.Shader.Draw(context);
}
public int ZIndex { get; set; }
}
}

View file

@ -1,36 +1,37 @@
using System.Drawing;
using OpenTK;
#region usings
using System.Drawing;
using OpenTK.Graphics;
using SM.Base.Contexts;
using SM.Base.Scene;
using SM.Base.Textures;
using SM.Base.Types;
using SM2D.Scene;
using SM2D.Types;
#endregion
namespace SM2D.Drawing
{
public class DrawTexture : DrawColor
{
public static float MasterScale = .25f;
public bool ManualSize = false;
public float Scale = 1;
public bool ManualSize = false;
public Texture Texture
public DrawTexture()
{
get => (Texture) _material.Texture;
set => _material.Texture = value;
}
public DrawTexture() {}
protected DrawTexture(Color4 color) : base(color) { }
protected DrawTexture(Color4 color) : base(color)
{
}
public DrawTexture(Bitmap map) : this(map, Color4.White)
{ }
{
}
public DrawTexture(Bitmap map, Color4 color) : this((Texture)map, color)
{ }
public DrawTexture(Bitmap map, Color4 color) : this((Texture) map, color)
{
}
public DrawTexture(Texture texture, Color4 color)
{
@ -38,9 +39,17 @@ namespace SM2D.Drawing
_material.Tint = color;
}
public Texture Texture
{
get => (Texture) _material.Texture;
set => _material.Texture = value;
}
protected override void DrawContext(ref DrawContext context)
{
if (!ManualSize) Transform.Size = new CVector2(Texture.Map.Width * MasterScale * Scale, Texture.Map.Height * MasterScale * Scale);
if (!ManualSize)
Transform.Size = new CVector2(Texture.Map.Width * MasterScale * Scale,
Texture.Map.Height * MasterScale * Scale);
base.DrawContext(ref context);
}
}

View file

@ -1,29 +1,31 @@
using System;
#region usings
using System;
using OpenTK;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Input;
using SM.Base;
using SM.Base.Controls;
using SM2D.Controls;
using SM2D.Pipelines;
using SM2D.Scene;
using SM2D.Shader;
using Vector2 = OpenTK.Vector2;
#endregion
namespace SM2D
{
public class GLWindow2D : GenericWindow<Scene.Scene, Camera>
{
public Vector2? Scaling { get; set; }
public Vector2 WorldScale => _worldScale;
public Mouse2D Mouse { get; }
public GLWindow2D()
{
Mouse = new Mouse2D(this);
}
public Vector2? Scaling { get; set; }
public Vector2 WorldScale => _worldScale;
public Mouse2D Mouse { get; }
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
@ -34,6 +36,8 @@ namespace SM2D
protected override void OnLoaded()
{
base.OnLoaded();
SMRenderer.DefaultMaterialShader = Default2DShader.MaterialShader;
SetRenderPipeline(new Basic2DPipeline());
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
#region usings
using System;
using System.Collections.Generic;
using OpenTK;
using OpenTK.Graphics;
@ -7,46 +8,40 @@ using OpenTK.Graphics.OpenGL4;
using SM.Base.Objects;
using SM.OGL.Mesh;
#endregion
namespace SM2D.Object
{
public class Polygon : Mesh
{
public override VBO Vertex { get; } = new VBO();
public override VBO UVs { get; } = new VBO(pointerSize:2);
public override VBO Color { get; } = new VBO(pointerSize: 4);
public override PrimitiveType PrimitiveType { get; } = PrimitiveType.TriangleFan;
public Polygon(ICollection<Vector2> vertices)
{
foreach (Vector2 vertex in vertices)
foreach (var vertex in vertices)
{
Color.Add(Color4.White);
AddVertex(vertex);
}
foreach (Vector2 vertex in vertices)
{
AddUV(vertex);
}
foreach (var vertex in vertices) AddUV(vertex);
}
public Polygon(ICollection<PolygonVertex> vertices)
{
foreach (PolygonVertex polygonVertex in vertices)
foreach (var polygonVertex in vertices)
{
Color.Add(polygonVertex.Color);
AddVertex(polygonVertex.Vertex);
}
foreach (PolygonVertex vertex in vertices)
{
AddUV(vertex.Vertex);
}
foreach (var vertex in vertices) AddUV(vertex.Vertex);
}
public override VBO Vertex { get; } = new VBO();
public override VBO UVs { get; } = new VBO(pointerSize: 2);
public override VBO Color { get; } = new VBO(pointerSize: 4);
public override PrimitiveType PrimitiveType { get; } = PrimitiveType.TriangleFan;
private void AddVertex(Vector2 vertex)
{
BoundingBox.Update(vertex);
@ -55,18 +50,19 @@ namespace SM2D.Object
private void AddUV(Vector2 vertex)
{
Vector2 uv = Vector2.Divide(vertex, BoundingBox.Max.Xy) + BoundingBox.Min.Xy;
var uv = Vector2.Divide(vertex, BoundingBox.Max.Xy) + BoundingBox.Min.Xy;
UVs.Add(uv);
}
public static Polygon GenerateCircle(int secments = 32)
{
List<Vector2> vertices = new List<Vector2>() {Vector2.Zero};
var vertices = new List<Vector2> {Vector2.Zero};
float step = 360f / secments;
for (int i = 0; i < secments + 1; i++)
var step = 360f / secments;
for (var i = 0; i < secments + 1; i++)
{
Vector2 vertex = new Vector2( 0.5f * (float)Math.Cos(step * i * Math.PI / 180f), 0.5f * (float)Math.Sin(step * i * Math.PI / 180f));
var vertex = new Vector2(0.5f * (float) Math.Cos(step * i * Math.PI / 180f),
0.5f * (float) Math.Sin(step * i * Math.PI / 180f));
vertices.Add(vertex);
}

View file

@ -1,6 +1,10 @@
using OpenTK;
#region usings
using OpenTK;
using OpenTK.Graphics;
#endregion
namespace SM2D.Object
{
public struct PolygonVertex

View file

@ -2,6 +2,5 @@
{
public class Adv2DPipeline
{
}
}

View file

@ -1,15 +1,18 @@
using OpenTK.Graphics.OpenGL4;
#region usings
using OpenTK.Graphics.OpenGL4;
using SM.Base;
using SM.Base.Contexts;
using SM.Base.Scene;
using SM.OGL.Framebuffer;
using SM2D.Shader;
#endregion
namespace SM2D.Pipelines
{
public class Basic2DPipeline : RenderPipeline<Scene.Scene>
{
protected override IShader _defaultShader { get; } = Default2DShader.Shader;
protected override void Render(ref DrawContext context, Scene.Scene scene)
{

View file

@ -1,16 +1,19 @@
using System.Reflection;
using System.Runtime.CompilerServices;
#region usings
using System.Reflection;
using System.Runtime.InteropServices;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SM2D")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("SMRenderer for 2D-projects")]
[assembly: AssemblyDescription("Scene and Render system for 2D-projects")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyCompany("iedSoftworks")]
[assembly: AssemblyProduct("SM2D")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2020")]
[assembly: AssemblyCopyright("Copyright © iedSoftworks 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -33,4 +36,4 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -31,25 +31,21 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="OpenTK, Version=3.2.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\..\packages\OpenTK.3.2\lib\net20\OpenTK.dll</HintPath>
<Reference Include="OpenTK, Version=3.2.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\..\packages\OpenTK.3.2.1\lib\net20\OpenTK.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controls\Mouse2D.cs" />
<Compile Include="Drawing\DrawBackground.cs" />
<Compile Include="Drawing\DrawBackgroundShader.cs" />
<Compile Include="Drawing\DrawColor.cs" />
<Compile Include="Drawing\DrawComplex.cs" />
<Compile Include="Drawing\DrawPolygon.cs" />
<Compile Include="Drawing\DrawShader.cs" />
<Compile Include="Drawing\DrawText.cs" />
<Compile Include="Drawing\DrawTexture.cs" />
<Compile Include="GLWindow2D.cs" />
@ -76,11 +72,12 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
<EmbeddedResource Include="Shader\ShaderFiles\default.frag" />
<EmbeddedResource Include="Shader\ShaderFiles\default.vert" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -1,23 +1,27 @@
using OpenTK;
#region usings
using OpenTK;
using SM.Base.Scene;
using SM.Base.Types;
#endregion
namespace SM2D.Scene
{
public class Camera : GenericCamera
{
public override bool Orthographic { get; } = true;
public CVector2 Position = new CVector2(0);
public override bool Orthographic { get; } = true;
protected override Matrix4 ViewCalculation()
{
return Matrix4.LookAt(Position.X, Position.Y, 2, Position.X, Position.Y, 0, 0, 1, 0);
}
public override void RecalculateWorld(OpenTK.Vector2 world, float aspect)
public override void RecalculateWorld(Vector2 world, float aspect)
{
OrthographicWorld = Matrix4.CreateOrthographicOffCenter(-world.X / 2, world.X / 2, world.Y / 2, -world.Y / 2, 0.1f, 4f);
OrthographicWorld =
Matrix4.CreateOrthographicOffCenter(-world.X / 2, world.X / 2, world.Y / 2, -world.Y / 2, 0.1f, 4f);
}
}
}

View file

@ -1,10 +1,13 @@
using SM.Base.Scene;
#region usings
using SM.Base.Scene;
#endregion
namespace SM2D.Scene
{
public interface I2DShowItem : IShowItem
{
int ZIndex { get; set; }
}
}

View file

@ -1,8 +1,12 @@
using SM.Base.Contexts;
#region usings
using SM.Base.Contexts;
using SM.Base.Scene;
using SM.Base.Types;
using SM2D.Types;
#endregion
namespace SM2D.Scene
{
public class ItemCollection : GenericItemCollection<I2DShowItem, Transformation>, I2DShowItem

View file

@ -1,17 +1,20 @@
using OpenTK.Graphics;
using SM.Base.Contexts;
#region usings
using OpenTK.Graphics;
using SM.Base.Scene;
using SM2D.Drawing;
#endregion
namespace SM2D.Scene
{
public class Scene : GenericScene<Camera, ItemCollection, I2DShowItem>
{
public DrawBackground Background => (DrawBackground)_Background;
public Scene()
{
_Background = new DrawBackground(Color4.Black);
}
public DrawBackground Background => (DrawBackground) _Background;
}
}

View file

@ -1,14 +1,18 @@
using OpenTK.Graphics.OpenGL4;
#region usings
using OpenTK.Graphics.OpenGL4;
using SM.Base.Contexts;
using SM.Base.Scene;
using SM.OGL.Shaders;
using SM.Utility;
#endregion
namespace SM2D.Shader
{
public class Default2DShader : GenericShader, IShader
public class Default2DShader : MaterialShader
{
public static Default2DShader Shader = new Default2DShader();
public static Default2DShader MaterialShader = new Default2DShader();
//protected override bool AutoCompile { get; } = true;
@ -18,32 +22,31 @@ namespace SM2D.Shader
{
Load();
}
public void Draw(DrawContext context)
protected override void DrawProcess(DrawContext context)
{
GL.UseProgram(this);
GL.BindVertexArray(context.Mesh);
// Vertex Uniforms
Uniforms["MVP"].SetMatrix4(context.ModelMaster * context.View * context.World);
Uniforms["HasVColor"].SetUniform1(context.Mesh.AttribDataIndex.ContainsKey(3) && context.Mesh.AttribDataIndex[3] != null);
Uniforms["HasVColor"]
.SetUniform1(context.Mesh.AttribDataIndex.ContainsKey(3) && context.Mesh.AttribDataIndex[3] != null);
for (int i = 0; i < context.Instances.Length; i++)
Uniforms.GetArray("Instances").Set((i, uniforms) =>
{
GL.UniformMatrix4(Uniforms["ModelMatrix"] + i, false, ref context.Instances[i].ModelMatrix);
GL.Uniform2(Uniforms["TextureOffset"] + i, context.Instances[i].TexturePosition);
GL.Uniform2(Uniforms["TextureScale"] + i, context.Instances[i].TextureScale);
}
if (i >= context.Instances.Length) return false;
var instance = context.Instances[i];
uniforms["ModelMatrix"].SetMatrix4(instance.ModelMatrix);
uniforms["TextureOffset"].SetUniform2(instance.TexturePosition);
uniforms["TextureScale"].SetUniform2(instance.TextureScale);
return true;
});
// Fragment Uniforms
Uniforms["Tint"].SetUniform4(context.Material.Tint);
Uniforms["Texture"].SetTexture(context.Material.Texture, Uniforms["UseTexture"]);
DrawObject(context.Mesh, context.Instances.Length);
CleanUp();
GL.UseProgram(0);
}
}
}

View file

@ -1,23 +1,12 @@
#version 330
#define maxInstances 32
layout(location = 0) in vec3 aPos;
layout(location = 1) in vec2 aTex;
layout(location = 3) in vec4 aColor;
uniform mat4 MVP;
uniform bool HasVColor;
uniform mat4 ModelMatrix[maxInstances];
uniform vec2 TextureOffset[maxInstances];
uniform vec2 TextureScale[maxInstances];
out vec2 vTexture;
out vec4 vColor;
//# import SM_base_vertex_basic
void ApplyTexModifier();
void CheckVertexColor();
void ApplyModelTransformation();
void main() {
vTexture = aTex * TextureScale[gl_InstanceID] + TextureOffset[gl_InstanceID];
if (HasVColor) vColor = aColor;
else vColor = vec4(1);
gl_Position = MVP * ModelMatrix[gl_InstanceID] * vec4(aPos, 1);
ApplyTexModifier();
CheckVertexColor();
ApplyModelTransformation();
}

View file

@ -1,52 +1,39 @@
using System;
using System.Configuration.Assemblies;
#region usings
using OpenTK;
using SM.Base.Scene;
using SM.Base.Types;
using SM.Utility;
#endregion
namespace SM2D.Types
{
public class Transformation : GenericTransformation
{
private float _eulerRotation = 0;
private CVector2 _position = new CVector2(0);
private CVector2 _scale = new CVector2(50);
public CVector2 Position { get; set; } = new CVector2(0);
public CVector2 Position
{
get => _position;
set => _position = value;
}
public CVector2 Size { get; set; } = new CVector2(50);
public CVector2 Size
{
get => _scale;
set => _scale = value;
}
public float Rotation
{
get => _eulerRotation;
set => _eulerRotation = value;
}
public float Rotation { get; set; }
protected override Matrix4 RequestMatrix()
{
return Matrix4.CreateScale(_scale.X, _scale.Y, 1) *
Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(_eulerRotation)) *
Matrix4.CreateTranslation(_position.X, _position.Y, 0);
return Matrix4.CreateScale(Size.X, Size.Y, 1) *
Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(Rotation)) *
Matrix4.CreateTranslation(Position.X, Position.Y, 0);
}
public void TurnTo(Vector2 v)
{
_eulerRotation = RotationUtility.TurnTowards(Position, v);
Rotation = RotationUtility.TurnTowards(Position, v);
}
public Vector2 LookAtVector()
{
if (_modelMatrix.Determinant < 0.0001) return new Vector2(0);
Vector3 vec = Vector3.TransformNormal(Vector3.UnitX, _modelMatrix);
var vec = Vector3.TransformNormal(Vector3.UnitX, _modelMatrix);
vec.Normalize();
return vec.Xy;
}

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="OpenTK" version="3.2" targetFramework="net452" />
<package id="OpenTK" version="3.2.1" targetFramework="net452" />
</packages>