Add enemy paths to muunt editor
This commit is contained in:
parent
9c28afdfe2
commit
3bccc3ca5e
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -8,8 +8,10 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
|
||||
{
|
||||
public class PathPoint : IObject
|
||||
{
|
||||
public Action OnPathMoved;
|
||||
|
||||
[Browsable(false)]
|
||||
public RenderablePathPoint RenderablePoint
|
||||
public virtual RenderablePathPoint RenderablePoint
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -66,9 +68,12 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
|
||||
get { return new Vector3(this[N_Scale]["X"], this[N_Scale]["Y"], this[N_Scale]["Z"]); ; }
|
||||
set
|
||||
{
|
||||
this[N_Scale]["X"] = value.X;
|
||||
this[N_Scale]["Y"] = value.Y;
|
||||
this[N_Scale]["Z"] = value.Z;
|
||||
if (this[N_Scale] != null)
|
||||
{
|
||||
this[N_Scale]["X"] = value.X;
|
||||
this[N_Scale]["Y"] = value.Y;
|
||||
this[N_Scale]["Z"] = value.Z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ namespace GL_EditorFramework.EditorDrawables
|
||||
{
|
||||
public class RenderablePathPoint : EditableObject
|
||||
{
|
||||
public bool CanConnect = true;
|
||||
|
||||
public object NodeObject;
|
||||
|
||||
public bool IsNormalTanTransform = false;
|
||||
@ -166,9 +168,7 @@ namespace GL_EditorFramework.EditorDrawables
|
||||
UpdateNodePosition();
|
||||
}
|
||||
|
||||
public virtual void UpdatePosition(int subObj)
|
||||
{
|
||||
|
||||
public virtual void UpdatePosition(int subObj) {
|
||||
}
|
||||
|
||||
public override bool CanStartDragging() => true;
|
||||
@ -225,6 +225,9 @@ namespace GL_EditorFramework.EditorDrawables
|
||||
((PathPoint)NodeObject).Translate = position;
|
||||
((PathPoint)NodeObject).Scale = scale;
|
||||
((PathPoint)NodeObject).Rotate = rotate;
|
||||
|
||||
if (((PathPoint)NodeObject).OnPathMoved != null)
|
||||
((PathPoint)NodeObject).OnPathMoved();
|
||||
}
|
||||
}
|
||||
|
@ -159,12 +159,14 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
|
||||
}
|
||||
|
||||
public List<LapPathGroup> LapPaths;
|
||||
|
||||
public List<EnemyPathGroup> EnemyPaths;
|
||||
|
||||
public CourseMuuntScene(dynamic rootNode)
|
||||
{
|
||||
root = rootNode;
|
||||
|
||||
LapPaths = new List<LapPathGroup>();
|
||||
EnemyPaths = new List<EnemyPathGroup>();
|
||||
|
||||
if (root.ContainsKey("Area")) {
|
||||
foreach (var area in root["Area"])
|
||||
@ -191,8 +193,9 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
|
||||
{ }
|
||||
}
|
||||
if (root.ContainsKey("EnemyPath")) {
|
||||
foreach (var enemyPath in root["EnemyPath"])
|
||||
{ }
|
||||
foreach (var enemyPath in root["EnemyPath"]) {
|
||||
EnemyPaths.Add(new EnemyPathGroup(enemyPath));
|
||||
}
|
||||
}
|
||||
if (root.ContainsKey("GravityPath")) {
|
||||
foreach (var gravityPath in root["GravityPath"])
|
||||
@ -272,116 +275,6 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
|
||||
|
||||
}
|
||||
|
||||
public class LapPathGroup : IObject
|
||||
{
|
||||
public const string N_LapPathGroup = "LapPathGroup";
|
||||
public const string N_ReturnPointsError = "ReturnPointsError";
|
||||
public const string N_UnitIdNum = "UnitIdNum";
|
||||
|
||||
public List<PathPoint> PathPoints = new List<PathPoint>();
|
||||
public List<ReturnPoint> ReturnPoints = new List<ReturnPoint>();
|
||||
|
||||
public LapPathGroup(dynamic bymlNode)
|
||||
{
|
||||
if (bymlNode is Dictionary<string, dynamic>) Prop = (Dictionary<string, dynamic>)bymlNode;
|
||||
else throw new Exception("Not a dictionary");
|
||||
|
||||
foreach (var point in this["PathPt"]) {
|
||||
PathPoints.Add(new LapPatPoint(point));
|
||||
}
|
||||
|
||||
foreach (var point in this["ReturnPoints"]) {
|
||||
ReturnPoints.Add(new ReturnPoint(point));
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public Dictionary<string, dynamic> Prop { get; set; } = new Dictionary<string, dynamic>();
|
||||
|
||||
public int LapPathGroupId
|
||||
{
|
||||
get { return this[N_LapPathGroup]; }
|
||||
set { this[N_LapPathGroup] = value; }
|
||||
}
|
||||
|
||||
public int ReturnPointsError
|
||||
{
|
||||
get { return this[N_ReturnPointsError]; }
|
||||
set { this[N_ReturnPointsError] = value; }
|
||||
}
|
||||
|
||||
public int UnitIdNum
|
||||
{
|
||||
get { return this[N_UnitIdNum]; }
|
||||
set { this[N_UnitIdNum] = value; }
|
||||
}
|
||||
|
||||
public dynamic this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Prop.ContainsKey(name)) return Prop[name];
|
||||
else return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (Prop.ContainsKey(name)) Prop[name] = value;
|
||||
else Prop.Add(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LapPatPoint: PathPoint
|
||||
{
|
||||
[Category("Properties")]
|
||||
public int CheckPoint
|
||||
{
|
||||
get { return this["CheckPoint"]; }
|
||||
set { this["CheckPoint"] = value;}
|
||||
}
|
||||
|
||||
[Category("Properties")]
|
||||
public int ClipIdx
|
||||
{
|
||||
get { return this["ClipIdx"]; }
|
||||
set { this["ClipIdx"] = value; }
|
||||
}
|
||||
|
||||
[Category("Properties")]
|
||||
public bool HeadLightSW
|
||||
{
|
||||
get { return this["HeadLightSW"]; }
|
||||
set { this["HeadLightSW"] = value; }
|
||||
}
|
||||
|
||||
[Category("Properties")]
|
||||
public int LapCheck
|
||||
{
|
||||
get { return this["LapCheck"]; }
|
||||
set { this["LapCheck"] = value; }
|
||||
}
|
||||
|
||||
[Category("Properties")]
|
||||
public int MapCameraFovy
|
||||
{
|
||||
get { return this["MapCameraFovy"]; }
|
||||
set { this["MapCameraFovy"] = value; }
|
||||
}
|
||||
|
||||
[Category("Properties")]
|
||||
public int MapCameraY
|
||||
{
|
||||
get { return this["MapCameraY"]; }
|
||||
set { this["MapCameraY"] = value; }
|
||||
}
|
||||
|
||||
public LapPatPoint(dynamic bymlNode)
|
||||
{
|
||||
if (bymlNode is Dictionary<string, dynamic>) Prop = (Dictionary<string, dynamic>)bymlNode;
|
||||
else throw new Exception("Not a dictionary");
|
||||
}
|
||||
}
|
||||
|
||||
public class PointID : IObject
|
||||
{
|
||||
public int PathID
|
||||
|
193
Switch_FileFormatsMain/GUI/Byaml/CourseMuunt/Paths/EnemyPaths.cs
Normal file
193
Switch_FileFormatsMain/GUI/Byaml/CourseMuunt/Paths/EnemyPaths.cs
Normal file
@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using GL_EditorFramework.EditorDrawables;
|
||||
using GL_EditorFramework.GL_Core;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using OpenTK;
|
||||
using System.Drawing;
|
||||
|
||||
namespace FirstPlugin.Turbo.CourseMuuntStructs
|
||||
{
|
||||
public class RenderablePaths : AbstractGlDrawable
|
||||
{
|
||||
private static ShaderProgram defaultShaderProgram;
|
||||
|
||||
public List<EnemyPathGroup> PathGroups = new List<EnemyPathGroup>();
|
||||
|
||||
public override void Prepare(GL_ControlLegacy control)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Prepare(GL_ControlModern control)
|
||||
{
|
||||
var defaultFrag = new FragmentShader(
|
||||
@"#version 330
|
||||
void main(){
|
||||
gl_FragColor = vec4(0,1,0,1);
|
||||
}");
|
||||
|
||||
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)
|
||||
{
|
||||
GL.LineWidth(2f);
|
||||
foreach (var nextPt in path.NextPoints)
|
||||
{
|
||||
GL.Color3(Color.Blue);
|
||||
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(Color.Blue);
|
||||
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;
|
||||
|
||||
foreach (var group in PathGroups)
|
||||
{
|
||||
foreach (var path in group.PathPoints)
|
||||
{
|
||||
GL.LineWidth(2f);
|
||||
foreach (var nextPt in path.NextPoints)
|
||||
{
|
||||
GL.Color3(Color.Blue);
|
||||
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(Color.Blue);
|
||||
GL.Begin(PrimitiveType.Lines);
|
||||
GL.Vertex3(path.Translate);
|
||||
GL.Vertex3(PathGroups[prevPt.PathID].PathPoints[prevPt.PtID].Translate);
|
||||
GL.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EnemyPathGroup : IObject
|
||||
{
|
||||
public const string N_EnemyPathGroup = "EnemyPathGroup";
|
||||
public const string N_UnitIdNum = "UnitIdNum";
|
||||
|
||||
public List<PathPoint> PathPoints = new List<PathPoint>();
|
||||
|
||||
public EnemyPathGroup(dynamic bymlNode)
|
||||
{
|
||||
if (bymlNode is Dictionary<string, dynamic>) Prop = (Dictionary<string, dynamic>)bymlNode;
|
||||
else throw new Exception("Not a dictionary");
|
||||
|
||||
foreach (var point in this["PathPt"])
|
||||
{
|
||||
PathPoints.Add(new EnemyPathPoint(point));
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public Dictionary<string, dynamic> Prop { get; set; } = new Dictionary<string, dynamic>();
|
||||
|
||||
public int EnemyPathGroupId
|
||||
{
|
||||
get { return this[N_EnemyPathGroup]; }
|
||||
set { this[N_EnemyPathGroup] = value; }
|
||||
}
|
||||
|
||||
public int UnitIdNum
|
||||
{
|
||||
get { return this[N_UnitIdNum]; }
|
||||
set { this[N_UnitIdNum] = value; }
|
||||
}
|
||||
|
||||
public dynamic this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Prop.ContainsKey(name)) return Prop[name];
|
||||
else return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (Prop.ContainsKey(name)) Prop[name] = value;
|
||||
else Prop.Add(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EnemyPathPoint : PathPoint
|
||||
{
|
||||
[Browsable(false)]
|
||||
public override RenderablePathPoint RenderablePoint
|
||||
{
|
||||
get
|
||||
{
|
||||
var point = new RenderablePathPoint(Translate, Rotate, new OpenTK.Vector3(30), this);
|
||||
point.CanConnect = true;
|
||||
return point;
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Properties")]
|
||||
public int BattleFlag
|
||||
{
|
||||
get { return this["BattleFlag"]; }
|
||||
set { this["BattleFlag"] = value; }
|
||||
}
|
||||
|
||||
[Category("Properties")]
|
||||
public int Priority
|
||||
{
|
||||
get { return this["Priority"]; }
|
||||
set { this["Priority"] = value; }
|
||||
}
|
||||
|
||||
public EnemyPathPoint(dynamic bymlNode)
|
||||
{
|
||||
if (bymlNode is Dictionary<string, dynamic>) Prop = (Dictionary<string, dynamic>)bymlNode;
|
||||
else throw new Exception("Not a dictionary");
|
||||
|
||||
foreach (var point in this["NextPt"])
|
||||
{
|
||||
NextPoints.Add(new PointID(point));
|
||||
}
|
||||
foreach (var point in this["PrevPt"])
|
||||
{
|
||||
PrevPoints.Add(new PointID(point));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
130
Switch_FileFormatsMain/GUI/Byaml/CourseMuunt/Paths/LapPaths.cs
Normal file
130
Switch_FileFormatsMain/GUI/Byaml/CourseMuunt/Paths/LapPaths.cs
Normal file
@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FirstPlugin.Turbo.CourseMuuntStructs
|
||||
{
|
||||
public class LapPathGroup : IObject
|
||||
{
|
||||
public const string N_LapPathGroup = "LapPathGroup";
|
||||
public const string N_ReturnPointsError = "ReturnPointsError";
|
||||
public const string N_UnitIdNum = "UnitIdNum";
|
||||
|
||||
public List<PathPoint> PathPoints = new List<PathPoint>();
|
||||
public List<ReturnPoint> ReturnPoints = new List<ReturnPoint>();
|
||||
|
||||
public LapPathGroup(dynamic bymlNode)
|
||||
{
|
||||
if (bymlNode is Dictionary<string, dynamic>) Prop = (Dictionary<string, dynamic>)bymlNode;
|
||||
else throw new Exception("Not a dictionary");
|
||||
|
||||
foreach (var point in this["PathPt"])
|
||||
{
|
||||
PathPoints.Add(new LapPathPoint(point));
|
||||
}
|
||||
|
||||
foreach (var point in this["ReturnPoints"])
|
||||
{
|
||||
ReturnPoints.Add(new ReturnPoint(point));
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public Dictionary<string, dynamic> Prop { get; set; } = new Dictionary<string, dynamic>();
|
||||
|
||||
public int LapPathGroupId
|
||||
{
|
||||
get { return this[N_LapPathGroup]; }
|
||||
set { this[N_LapPathGroup] = value; }
|
||||
}
|
||||
|
||||
public int ReturnPointsError
|
||||
{
|
||||
get { return this[N_ReturnPointsError]; }
|
||||
set { this[N_ReturnPointsError] = value; }
|
||||
}
|
||||
|
||||
public int UnitIdNum
|
||||
{
|
||||
get { return this[N_UnitIdNum]; }
|
||||
set { this[N_UnitIdNum] = value; }
|
||||
}
|
||||
|
||||
public dynamic this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Prop.ContainsKey(name)) return Prop[name];
|
||||
else return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (Prop.ContainsKey(name)) Prop[name] = value;
|
||||
else Prop.Add(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LapPathPoint : PathPoint
|
||||
{
|
||||
[Category("Properties")]
|
||||
public int CheckPoint
|
||||
{
|
||||
get { return this["CheckPoint"]; }
|
||||
set { this["CheckPoint"] = value; }
|
||||
}
|
||||
|
||||
[Category("Properties")]
|
||||
public int ClipIdx
|
||||
{
|
||||
get { return this["ClipIdx"]; }
|
||||
set { this["ClipIdx"] = value; }
|
||||
}
|
||||
|
||||
[Category("Properties")]
|
||||
public bool HeadLightSW
|
||||
{
|
||||
get { return this["HeadLightSW"]; }
|
||||
set { this["HeadLightSW"] = value; }
|
||||
}
|
||||
|
||||
[Category("Properties")]
|
||||
public int LapCheck
|
||||
{
|
||||
get { return this["LapCheck"]; }
|
||||
set { this["LapCheck"] = value; }
|
||||
}
|
||||
|
||||
[Category("Properties")]
|
||||
public int MapCameraFovy
|
||||
{
|
||||
get { return this["MapCameraFovy"]; }
|
||||
set { this["MapCameraFovy"] = value; }
|
||||
}
|
||||
|
||||
[Category("Properties")]
|
||||
public int MapCameraY
|
||||
{
|
||||
get { return this["MapCameraY"]; }
|
||||
set { this["MapCameraY"] = value; }
|
||||
}
|
||||
|
||||
public LapPathPoint(dynamic bymlNode)
|
||||
{
|
||||
if (bymlNode is Dictionary<string, dynamic>) Prop = (Dictionary<string, dynamic>)bymlNode;
|
||||
else throw new Exception("Not a dictionary");
|
||||
|
||||
foreach (var point in this["NextPt"])
|
||||
{
|
||||
NextPoints.Add(new PointID(point));
|
||||
}
|
||||
foreach (var point in this["PrevPt"])
|
||||
{
|
||||
PrevPoints.Add(new PointID(point));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -8,6 +8,8 @@ using Switch_Toolbox.Library;
|
||||
using System.Windows.Forms;
|
||||
using FirstPlugin.Turbo.CourseMuuntStructs;
|
||||
using GL_EditorFramework.EditorDrawables;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace FirstPlugin.Forms
|
||||
{
|
||||
@ -72,10 +74,34 @@ namespace FirstPlugin.Forms
|
||||
{
|
||||
foreach (var path in group.PathPoints)
|
||||
{
|
||||
path.OnPathMoved = OnPathMoved;
|
||||
viewport.AddDrawable(path.RenderablePoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scene.EnemyPaths.Count > 0)
|
||||
{
|
||||
objectCB.Items.Add("Enemy Paths");
|
||||
var renderablePath = new RenderablePaths();
|
||||
renderablePath.PathGroups = scene.EnemyPaths;
|
||||
viewport.AddDrawable(renderablePath);
|
||||
|
||||
foreach (var group in scene.EnemyPaths)
|
||||
{
|
||||
foreach (var path in group.PathPoints)
|
||||
{
|
||||
path.OnPathMoved = OnPathMoved;
|
||||
viewport.AddDrawable(path.RenderablePoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void OnPathMoved() {
|
||||
stPropertyGrid1.Refresh();
|
||||
}
|
||||
|
||||
private void Scene_SelectionChanged(object sender, EventArgs e)
|
||||
|
@ -330,9 +330,11 @@
|
||||
</Compile>
|
||||
<Compile Include="GUI\Byaml\CourseMuunt\CourseMuuntStructs.cs" />
|
||||
<Compile Include="GUI\Byaml\CourseMuunt\IObject.cs" />
|
||||
<Compile Include="GUI\Byaml\CourseMuunt\RenderablePathPoint.cs" />
|
||||
<Compile Include="GUI\Byaml\CourseMuunt\ReturnPoint.cs" />
|
||||
<Compile Include="GUI\Byaml\CourseMuunt\PathPoint.cs" />
|
||||
<Compile Include="GUI\Byaml\CourseMuunt\Paths\EnemyPaths.cs" />
|
||||
<Compile Include="GUI\Byaml\CourseMuunt\Paths\LapPaths.cs" />
|
||||
<Compile Include="GUI\Byaml\CourseMuunt\Base\RenderablePathPoint.cs" />
|
||||
<Compile Include="GUI\Byaml\CourseMuunt\Paths\ReturnPoint.cs" />
|
||||
<Compile Include="GUI\Byaml\CourseMuunt\Base\PathPoint.cs" />
|
||||
<Compile Include="GUI\Byaml\CourseMuunt\TurboMunntEditor.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
e642c59851624ad96c53b6fc10b001a8b8197297
|
||||
5ef390c546d41f6a25da61da1f96e06785e1a7a0
|
||||
|
Loading…
x
Reference in New Issue
Block a user