2019-04-07 01:11:59 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using GL_EditorFramework.GL_Core;
|
|
|
|
|
using GL_EditorFramework.Interfaces;
|
|
|
|
|
using OpenTK.Graphics.OpenGL;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using System.Drawing;
|
2019-04-07 03:30:25 +02:00
|
|
|
|
using Switch_Toolbox.Library;
|
2019-04-07 01:11:59 +02:00
|
|
|
|
|
|
|
|
|
namespace FirstPlugin.Turbo.CourseMuuntStructs
|
|
|
|
|
{
|
|
|
|
|
public class RenderableConnectedPaths : AbstractGlDrawable
|
|
|
|
|
{
|
2019-04-07 02:34:12 +02:00
|
|
|
|
public Color LineColor = Color.Green;
|
|
|
|
|
|
|
|
|
|
public RenderableConnectedPaths(Color color) {
|
|
|
|
|
LineColor = color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Lap paths use 4 points for each rectangle
|
|
|
|
|
//This also applies to gravity paths
|
|
|
|
|
public bool Use4PointConnection = false;
|
|
|
|
|
|
2019-04-08 01:37:31 +02:00
|
|
|
|
private ShaderProgram defaultShaderProgram;
|
2019-04-07 01:11:59 +02:00
|
|
|
|
|
2019-04-08 03:14:39 +02:00
|
|
|
|
public List<BasePathGroup> PathGroups = new List<BasePathGroup>();
|
2019-04-07 01:11:59 +02:00
|
|
|
|
|
2019-04-07 02:34:12 +02:00
|
|
|
|
|
2019-04-08 03:14:39 +02:00
|
|
|
|
public void AddGroup(BasePathGroup group)
|
2019-04-07 01:11:59 +02:00
|
|
|
|
{
|
2019-04-08 03:14:39 +02:00
|
|
|
|
PathGroups.Add(new BasePathGroup()
|
2019-04-07 01:11:59 +02:00
|
|
|
|
{
|
|
|
|
|
PathPoints = group.PathPoints,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Prepare(GL_ControlLegacy control)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Prepare(GL_ControlModern control)
|
|
|
|
|
{
|
|
|
|
|
var defaultFrag = new FragmentShader(
|
2019-04-07 03:30:25 +02:00
|
|
|
|
@"#version 330
|
|
|
|
|
vec4 LineColor;
|
|
|
|
|
|
2019-04-07 01:11:59 +02:00
|
|
|
|
void main(){
|
2019-04-07 03:30:25 +02:00
|
|
|
|
gl_FragColor = LineColor;
|
2019-04-07 01:11:59 +02:00
|
|
|
|
}");
|
|
|
|
|
|
|
|
|
|
var defaultVert = new VertexShader(
|
|
|
|
|
@"#version 330
|
|
|
|
|
in vec4 position;
|
|
|
|
|
|
|
|
|
|
uniform mat4 mtxCam;
|
|
|
|
|
uniform mat4 mtxMdl;
|
|
|
|
|
|
|
|
|
|
void main(){
|
|
|
|
|
gl_Position = mtxCam * mtxMdl * vec4(position.xyz, 1);
|
|
|
|
|
}");
|
|
|
|
|
|
|
|
|
|
defaultShaderProgram = new ShaderProgram(defaultFrag, defaultVert);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Draw(GL_ControlLegacy control, Pass pass)
|
|
|
|
|
{
|
|
|
|
|
foreach (var group in PathGroups)
|
|
|
|
|
{
|
|
|
|
|
foreach (var path in group.PathPoints)
|
|
|
|
|
{
|
2019-04-08 01:37:31 +02:00
|
|
|
|
if (!path.RenderablePoint.Visible)
|
2019-04-07 02:16:41 +02:00
|
|
|
|
continue;
|
|
|
|
|
|
2019-04-07 01:11:59 +02:00
|
|
|
|
GL.LineWidth(2f);
|
|
|
|
|
foreach (var nextPt in path.NextPoints)
|
|
|
|
|
{
|
2019-04-07 02:34:12 +02:00
|
|
|
|
GL.Color3(LineColor);
|
2019-04-07 01:11:59 +02:00
|
|
|
|
GL.Begin(PrimitiveType.Lines);
|
|
|
|
|
GL.Vertex3(path.Translate);
|
|
|
|
|
GL.Vertex3(PathGroups[nextPt.PathID].PathPoints[nextPt.PtID].Translate);
|
|
|
|
|
GL.End();
|
|
|
|
|
}
|
|
|
|
|
foreach (var prevPt in path.PrevPoints)
|
|
|
|
|
{
|
2019-04-07 02:34:12 +02:00
|
|
|
|
GL.Color3(LineColor);
|
2019-04-07 01:11:59 +02:00
|
|
|
|
GL.Begin(PrimitiveType.Lines);
|
|
|
|
|
GL.Vertex3(path.Translate);
|
|
|
|
|
GL.Vertex3(PathGroups[prevPt.PathID].PathPoints[prevPt.PtID].Translate);
|
|
|
|
|
GL.End();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Draw(GL_ControlModern control, Pass pass)
|
|
|
|
|
{
|
|
|
|
|
control.CurrentShader = defaultShaderProgram;
|
2019-04-07 03:30:25 +02:00
|
|
|
|
defaultShaderProgram.SetVector4("LineColor", ColorUtility.ToVector4(LineColor));
|
2019-04-07 01:11:59 +02:00
|
|
|
|
|
|
|
|
|
foreach (var group in PathGroups)
|
|
|
|
|
{
|
|
|
|
|
foreach (var path in group.PathPoints)
|
|
|
|
|
{
|
2019-04-08 01:37:31 +02:00
|
|
|
|
if (!path.RenderablePoint.Visible)
|
2019-04-08 00:28:29 +02:00
|
|
|
|
continue;
|
|
|
|
|
|
2019-04-07 02:34:12 +02:00
|
|
|
|
if (Use4PointConnection)
|
2019-04-07 01:11:59 +02:00
|
|
|
|
{
|
2019-04-07 02:34:12 +02:00
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2019-04-07 01:11:59 +02:00
|
|
|
|
}
|
2019-04-07 02:34:12 +02:00
|
|
|
|
else
|
2019-04-07 01:11:59 +02:00
|
|
|
|
{
|
2019-04-07 02:34:12 +02:00
|
|
|
|
GL.LineWidth(2f);
|
|
|
|
|
foreach (var nextPt in path.NextPoints)
|
|
|
|
|
{
|
|
|
|
|
GL.Color3(LineColor);
|
|
|
|
|
GL.Begin(PrimitiveType.Lines);
|
|
|
|
|
GL.Vertex3(path.Translate);
|
|
|
|
|
GL.Vertex3(PathGroups[nextPt.PathID].PathPoints[nextPt.PtID].Translate);
|
|
|
|
|
GL.End();
|
|
|
|
|
}
|
|
|
|
|
foreach (var prevPt in path.PrevPoints)
|
|
|
|
|
{
|
|
|
|
|
GL.Color3(LineColor);
|
|
|
|
|
GL.Begin(PrimitiveType.Lines);
|
|
|
|
|
GL.Vertex3(path.Translate);
|
|
|
|
|
GL.Vertex3(PathGroups[prevPt.PathID].PathPoints[prevPt.PtID].Translate);
|
|
|
|
|
GL.End();
|
|
|
|
|
}
|
2019-04-07 01:11:59 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|