+ AxisHelper
~ Transformation can now set to be ignored. (Sending a Identity, when requested) ~ Changed how Meshes store Attributes
This commit is contained in:
parent
0895c600cf
commit
2e7051d800
14 changed files with 146 additions and 30 deletions
|
|
@ -11,6 +11,8 @@ namespace SM.Base.Drawing
|
|||
/// </summary>
|
||||
public abstract class GenericTransformation
|
||||
{
|
||||
public bool Ignore = false;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the current model matrix.
|
||||
/// </summary>
|
||||
|
|
@ -27,6 +29,8 @@ namespace SM.Base.Drawing
|
|||
/// <returns></returns>
|
||||
public Matrix4 GetMatrix()
|
||||
{
|
||||
if (Ignore) return Matrix4.Identity;
|
||||
|
||||
if (_lastFrame != SMRenderer.CurrentFrame)
|
||||
{
|
||||
_lastFrame = SMRenderer.CurrentFrame;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace SM.Base.Objects
|
|||
/// </summary>
|
||||
protected Mesh()
|
||||
{
|
||||
AttribDataIndex.Add(3, Color);
|
||||
Attributes.Add(3, "color", Color);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
35
SMCode/SM.Base/Objects/Static/AxisHelper.cs
Normal file
35
SMCode/SM.Base/Objects/Static/AxisHelper.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.OGL.Mesh;
|
||||
|
||||
namespace SM.Base.Objects.Static
|
||||
{
|
||||
public class AxisHelper : Mesh
|
||||
{
|
||||
public static AxisHelper Object = new AxisHelper();
|
||||
|
||||
private AxisHelper() {}
|
||||
|
||||
public override VBO Vertex { get; } = new VBO()
|
||||
{
|
||||
{0, 0, 0},
|
||||
{.5f, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, .5f, 0},
|
||||
{0, 0, -.5f},
|
||||
{0, 0, .5f},
|
||||
};
|
||||
|
||||
public override VBO Color { get; } = new VBO(pointerSize:4)
|
||||
{
|
||||
{Color4.White},
|
||||
{Color4.Red},
|
||||
{Color4.White},
|
||||
{Color4.Green},
|
||||
{Color4.White},
|
||||
{Color4.DarkBlue},
|
||||
};
|
||||
|
||||
public override PrimitiveType PrimitiveType { get; } = PrimitiveType.Lines;
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +56,7 @@
|
|||
<Compile Include="Drawing\Particles\ParticleDrawingBasis.cs" />
|
||||
<Compile Include="Log.cs" />
|
||||
<Compile Include="Objects\Mesh.cs" />
|
||||
<Compile Include="Objects\Static\AxisHelper.cs" />
|
||||
<Compile Include="PostProcess\PostProcessEffect.cs" />
|
||||
<Compile Include="PostProcess\PostProcessShader.cs" />
|
||||
<Compile Include="Scene\IScriptable.cs" />
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base.Drawing;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -13,8 +14,6 @@ namespace SM.Base.Scene
|
|||
/// </summary>
|
||||
public abstract class GenericScene
|
||||
{
|
||||
|
||||
|
||||
private IBackgroundItem _background;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -34,6 +33,7 @@ namespace SM.Base.Scene
|
|||
/// </summary>
|
||||
public bool IsInitialized { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates this scene.
|
||||
/// </summary>
|
||||
|
|
@ -91,6 +91,8 @@ namespace SM.Base.Scene
|
|||
private TCollection _hud = new TCollection();
|
||||
private TCollection _objectCollection = new TCollection();
|
||||
|
||||
public bool ShowAxisHelper { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// A collection for cameras to switch easier to different cameras.
|
||||
/// </summary>
|
||||
|
|
@ -154,6 +156,7 @@ namespace SM.Base.Scene
|
|||
DrawMainObjects(context);
|
||||
|
||||
DrawHUD(context);
|
||||
DrawDebug(context);
|
||||
}
|
||||
|
||||
public void DrawBackground(DrawContext context)
|
||||
|
|
@ -174,5 +177,10 @@ namespace SM.Base.Scene
|
|||
context.View = HUDCamera.CalculateViewMatrix();
|
||||
_hud.Draw(context);
|
||||
}
|
||||
|
||||
public virtual void DrawDebug(DrawContext context)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,6 @@
|
|||
#version 330
|
||||
#define maxInstances //!instanceMax
|
||||
|
||||
struct Instance {
|
||||
mat4 ModelMatrix;
|
||||
vec2 TextureOffset;
|
||||
vec2 TextureScale;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec2 aTex;
|
||||
|
|
@ -13,14 +8,13 @@ layout(location = 3) in vec4 aColor;
|
|||
|
||||
uniform mat4 MVP;
|
||||
uniform bool HasVColor;
|
||||
uniform Instance[maxInstances] Instances;
|
||||
|
||||
out vec2 vTexture;
|
||||
out vec4 vColor;
|
||||
out vec3 FragPos;
|
||||
|
||||
void ApplyTexModifier() {
|
||||
vTexture = aTex * Instances[gl_InstanceID].TextureScale + Instances[gl_InstanceID].TextureOffset;
|
||||
vTexture = aTex;
|
||||
}
|
||||
|
||||
void CheckVertexColor() {
|
||||
|
|
@ -29,7 +23,7 @@ void CheckVertexColor() {
|
|||
}
|
||||
|
||||
void ApplyModelTransformation() {
|
||||
gl_Position = MVP * Instances[gl_InstanceID].ModelMatrix * vec4(aPos, 1);
|
||||
gl_Position = MVP * vec4(aPos, 1);
|
||||
|
||||
FragPos = vec3(Instances[gl_InstanceID].ModelMatrix * vec4(aPos, 1));
|
||||
FragPos = vec3(vec4(aPos, 1));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue