2021-04-03

+ Added Field to DrawingBasis to enfore PrimitiveTypes
+ LastObject to context for Debugging
+ AppendRenderbuffer to Framebuffer

~ Added a depthbuffer to RenderPipeline.CreateWindowFramebuffer
~ Proper ZIndices over Z-Translation and DepthBuffer
~ Made "ShaderArguments["LineWidth"]" set the LineWidth even if the object isn't maked as LineMesh
~ Made that the SM2D.PolygonVertex can translate OpenTK.Vector2 by itself.
~ Made the SM2D.Transformation.ZIndex a CVector1 instead a float
This commit is contained in:
Michel Fedde 2021-03-04 22:17:03 +01:00
parent a7c71e7ea1
commit c6bf5c75bc
16 changed files with 114 additions and 26 deletions

View file

@ -57,7 +57,7 @@ namespace SM2D.Drawing
protected override void DrawContext(ref DrawContext context)
{
base.DrawContext(ref context);
context.ModelMatrix = Matrix4.CreateScale((context.UseCamera as Camera).WorldScale.X, (context.UseCamera as Camera).WorldScale.Y, 1);
context.ModelMatrix = Matrix4.CreateScale((context.UseCamera as Camera).WorldScale.X, (context.UseCamera as Camera).WorldScale.Y, 0) * Matrix4.CreateTranslation(0,0, -1.1f);
context.Shader.Draw(context);
}
}

View file

@ -17,5 +17,7 @@ namespace SM2D.Object
Vertex = vertex;
Color = color;
}
public static implicit operator PolygonVertex(Vector2 vec) => new PolygonVertex(vec, Color4.White);
}
}

View file

@ -38,7 +38,7 @@ namespace SM2D.Scene
protected override Matrix4 ViewCalculation(IGenericWindow window)
{
return Matrix4.LookAt(Position.X, Position.Y, 1, Position.X, Position.Y, 0, 0, 1, 0);
return Matrix4.LookAt(Position.X, Position.Y, 2f, Position.X, Position.Y, 0f, 0, 1, 0);
}
protected override bool WorldCalculation(IGenericWindow window, out Matrix4 world)
@ -50,7 +50,7 @@ namespace SM2D.Scene
_resizeCounter = ResizeCounter;
CalculateWorldScale(window);
world = Matrix4.CreateOrthographic(WorldScale.X, WorldScale.Y, .0001f, 1.5f);
world = Matrix4.CreateOrthographic(WorldScale.X, WorldScale.Y, .001f, 3.2f);
return true;
}

View file

@ -1,5 +1,6 @@
#region usings
using System.Drawing.Drawing2D;
using OpenTK;
using OpenTK.Graphics;
using SM.Base;
@ -39,6 +40,13 @@ namespace SM2D.Scene
set => _Background = value;
}
public override void DrawHUD(DrawContext context)
{
context.ModelMatrix *= Matrix4.CreateTranslation(0,0,1);
base.DrawHUD(context);
}
public override void DrawDebug(DrawContext context)
{
if (ShowAxisHelper)

View file

@ -27,15 +27,17 @@ namespace SM2D.Types
public bool VerticalFlip { get; set; } = false;
public int ZIndex { get; set; }
public CVector1 ZIndex { get; set; } = new CVector1(0);
protected override Matrix4 RequestMatrix()
{
float z = 1 / (float) ZIndexPercision * ZIndex;
return Matrix4.CreateScale(Size.X, Size.Y, 1) *
Matrix4.CreateRotationX(MathHelper.DegreesToRadians(HorizontalFlip ? 180 : 0)) *
Matrix4.CreateRotationY(MathHelper.DegreesToRadians(VerticalFlip ? 180 : 0)) *
Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(Rotation)) *
Matrix4.CreateTranslation(Position.X, Position.Y, -(1 / (float)ZIndexPercision * ZIndex));
Matrix4.CreateTranslation(Position.X, Position.Y, z);
}
public void TurnTo(Vector2 v)