Switch-Toolbox/File_Format_Library/GUI/Byaml/TurboCourseMuunt/RenderablePath.cs
KillzXGaming 8939687f6a Update files.
Load vertex positions for layouts in rectangle class. This will be used for proper rotation adjusting.
Add latest muunt editor files.
Add somewhat functional mk8 camera bin editor. Points can be moved around. The map orientation determines the position of the icons to map over the model.
Fix window content UV map for layouts.
Add 2D KCL renderer for top down KCL preview for both muunt and camera editors.
2019-10-26 20:28:56 -04:00

71 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using FirstPlugin.Turbo.CourseMuuntStructs;
using Toolbox.Library;
using Toolbox.Library.IO;
namespace FirstPlugin.MuuntEditor
{
/// <summary>
/// Represets a path with multiple grouped points that connect to each other
/// </summary>
public class RenderablePath : IDrawableObject
{
public Color LineColor = Color.Green;
public List<BasePathGroup> PathGroups = new List<BasePathGroup>();
public RenderablePath(List<BasePathGroup> pathGroups, Color color)
{
PathGroups = pathGroups;
LineColor = color;
}
public void Draw(Matrix4 mvp)
{
GL.Disable(EnableCap.DepthTest);
for (int i = 0; i < PathGroups.Count; i++)
{
foreach (var path in PathGroups[i].PathPoints)
{
var translate = new Vector3(path.Translate.X, path.Translate.Z, path.Translate.Y);
if (path.IsSelected)
Render2D.DrawFilledCircle(translate, Color.LightGreen, 30, 40, true);
else if (path.IsHovered)
Render2D.DrawFilledCircle(translate, LineColor.Lighten(40), 40, 40, true);
else
Render2D.DrawFilledCircle(translate, LineColor.Darken(20), 30, 40, true);
GL.LineWidth(2f);
foreach (var nextPt in path.NextPoints)
{
var nextTranslate = PathGroups[nextPt.PathID].PathPoints[nextPt.PtID].Translate;
GL.Color3(LineColor);
GL.Begin(PrimitiveType.Lines);
GL.Vertex3(translate);
GL.Vertex3(nextTranslate.X, nextTranslate.Z, nextTranslate.Y);
GL.End();
}
foreach (var prevPt in path.PrevPoints)
{
var prevTranslate = PathGroups[prevPt.PathID].PathPoints[prevPt.PtID].Translate;
GL.Color3(LineColor);
GL.Begin(PrimitiveType.Lines);
GL.Vertex3(translate);
GL.Vertex3(prevTranslate.X, prevTranslate.Z, prevTranslate.Y);
GL.End();
}
}
}
GL.Enable(EnableCap.DepthTest);
}
}
}