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.
This commit is contained in:
parent
1ed76ac2ac
commit
8939687f6a
@ -166,7 +166,7 @@ namespace FirstPlugin
|
||||
editor.Text = FileName;
|
||||
editor.Dock = DockStyle.Fill;
|
||||
|
||||
/* if (FileName.Contains("_muunt"))
|
||||
/* if (FileName.Contains("_muunt"))
|
||||
{
|
||||
var muuntEditor = new MuuntEditor.MuuntEditor();
|
||||
muuntEditor.LoadByaml(data.RootNode, FileName);
|
||||
|
@ -530,13 +530,12 @@ namespace LayoutBXLYT
|
||||
if (window.WindowKind == WindowKind.Horizontal)
|
||||
{
|
||||
//Left
|
||||
|
||||
texCoords = new Vector2[]
|
||||
{
|
||||
new Vector2(1, 0),
|
||||
new Vector2(0, 0),
|
||||
new Vector2(0, 1),
|
||||
new Vector2(1, 0),
|
||||
new Vector2(1, 1),
|
||||
new Vector2(0, 1),
|
||||
};
|
||||
|
||||
colors = new Color[] {
|
||||
@ -546,7 +545,7 @@ namespace LayoutBXLYT
|
||||
window.Content.ColorBottomRight.Color,
|
||||
};
|
||||
|
||||
DrawQuad(gameWindow, dX + frameRight + contentWidth, dY, frameRight, pane.Height, texCoords, colors, isSelected, hasTextures);
|
||||
DrawQuad(gameWindow, dX, dY, frameLeft, pane.Height, texCoords, colors, isSelected, hasTextures);
|
||||
|
||||
//Right
|
||||
|
||||
@ -559,10 +558,10 @@ namespace LayoutBXLYT
|
||||
|
||||
texCoords = new Vector2[]
|
||||
{
|
||||
new Vector2(0, 0),
|
||||
new Vector2(1, 0),
|
||||
new Vector2(1, 1),
|
||||
new Vector2(0, 0),
|
||||
new Vector2(0, 1),
|
||||
new Vector2(1, 1),
|
||||
};
|
||||
|
||||
colors = new Color[] {
|
||||
@ -572,7 +571,7 @@ namespace LayoutBXLYT
|
||||
window.Content.ColorBottomLeft.Color,
|
||||
};
|
||||
|
||||
DrawQuad(gameWindow, dX, dY, frameLeft, pane.Height, texCoords, colors, isSelected, hasTextures);
|
||||
DrawQuad(gameWindow, dX + frameRight + contentWidth, dY, frameRight, pane.Height, texCoords, colors, isSelected, hasTextures);
|
||||
}
|
||||
else if (window.WindowKind == WindowKind.HorizontalNoContent)
|
||||
{
|
||||
@ -806,10 +805,10 @@ namespace LayoutBXLYT
|
||||
var matBL = window.WindowFrames[2].Material;
|
||||
var matBR = window.WindowFrames[3].Material;
|
||||
|
||||
var matT = window.WindowFrames[4].Material;
|
||||
var matB = window.WindowFrames[5].Material;
|
||||
var matL = window.WindowFrames[6].Material;
|
||||
var matR = window.WindowFrames[7].Material;
|
||||
var matL = window.WindowFrames[4].Material;
|
||||
var matR = window.WindowFrames[5].Material;
|
||||
var matT = window.WindowFrames[6].Material;
|
||||
var matB = window.WindowFrames[7].Material;
|
||||
|
||||
//Todo check this
|
||||
if (window.UseOneMaterialForAll)
|
||||
@ -1125,16 +1124,16 @@ namespace LayoutBXLYT
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.Color4(colors[0]);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[0].X, texCoords[0].Y);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.BottomLeftPoint);
|
||||
GL.Color4(colors[1]);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[1].X, texCoords[1].Y);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.BottomRightPoint);
|
||||
GL.Color4(colors[2]);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[2].X, texCoords[2].Y);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.TopRightPoint);
|
||||
GL.Color4(colors[3]);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[3].X, texCoords[3].Y);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.TopLeftPoint);
|
||||
GL.End();
|
||||
}
|
||||
|
||||
@ -1311,10 +1310,10 @@ namespace LayoutBXLYT
|
||||
{
|
||||
GL.Begin(PrimitiveType.LineLoop);
|
||||
GL.Color4(selectionOutline ? Color.Red : colors[0]);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.BottomLeftPoint);
|
||||
GL.Vertex2(rect.BottomRightPoint);
|
||||
GL.Vertex2(rect.TopRightPoint);
|
||||
GL.Vertex2(rect.TopLeftPoint);
|
||||
GL.End();
|
||||
}
|
||||
else
|
||||
@ -1322,16 +1321,16 @@ namespace LayoutBXLYT
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.Color4(colors[0]);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[0].X, texCoords[0].Y);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.BottomLeftPoint);
|
||||
GL.Color4(colors[1]);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[1].X, texCoords[1].Y);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.BottomRightPoint);
|
||||
GL.Color4(colors[2]);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[2].X, texCoords[2].Y);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.TopRightPoint);
|
||||
GL.Color4(colors[3]);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[3].X, texCoords[3].Y);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.TopLeftPoint);
|
||||
GL.End();
|
||||
}
|
||||
}
|
||||
@ -1341,10 +1340,10 @@ namespace LayoutBXLYT
|
||||
pane.renderablePane = new RenderablePane();
|
||||
|
||||
Vector3[] vertices = new Vector3[4];
|
||||
vertices[0] = new Vector3(rect.LeftPoint, rect.BottomPoint, 0);
|
||||
vertices[1] = new Vector3(rect.RightPoint, rect.BottomPoint, 0);
|
||||
vertices[2] = new Vector3(rect.RightPoint, rect.TopPoint, 0);
|
||||
vertices[3] = new Vector3(rect.LeftPoint, rect.TopPoint, 0);
|
||||
vertices[0] = new Vector3(rect.BottomLeftPoint.X, rect.BottomLeftPoint.Y, 0);
|
||||
vertices[1] = new Vector3(rect.BottomRightPoint.X, rect.BottomRightPoint.Y, 0);
|
||||
vertices[2] = new Vector3(rect.TopRightPoint.X, rect.TopRightPoint.Y, 0);
|
||||
vertices[3] = new Vector3(rect.TopLeftPoint.X, rect.TopLeftPoint.Y, 0);
|
||||
Vector4[] vertexColors = new Vector4[4];
|
||||
|
||||
// pane.renderablePane.Render(vertices, vertexColors, texCoords);
|
||||
|
@ -1045,6 +1045,8 @@ namespace LayoutBXLYT.Cafe
|
||||
|
||||
public TXT1(FileReader reader, Header header) : base(reader, header)
|
||||
{
|
||||
layoutFile = header;
|
||||
|
||||
long startPos = reader.Position - 84;
|
||||
|
||||
TextLength = reader.ReadUInt16();
|
||||
@ -1671,12 +1673,19 @@ namespace LayoutBXLYT.Cafe
|
||||
}
|
||||
else if (Utils.GetExtension(file) == ".bflan")
|
||||
{
|
||||
var openedFile = STFileLoader.OpenFileFormat(file);
|
||||
if (openedFile == null)
|
||||
continue;
|
||||
try
|
||||
{
|
||||
var openedFile = STFileLoader.OpenFileFormat(file);
|
||||
if (openedFile == null)
|
||||
continue;
|
||||
|
||||
var bflan = openedFile as BXLAN;
|
||||
layoutFile.PartsManager.AddAnimation(bflan.BxlanHeader);
|
||||
var bflan = openedFile as BXLAN;
|
||||
layoutFile.PartsManager.AddAnimation(bflan.BxlanHeader);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else if (Utils.GetExtension(file) == ".bflyt")
|
||||
{
|
||||
@ -1732,17 +1741,24 @@ namespace LayoutBXLYT.Cafe
|
||||
}
|
||||
else if (file.FileName.Contains(LayoutFileName))
|
||||
{
|
||||
var openedFile = file.OpenFile();
|
||||
if (openedFile is IArchiveFile)
|
||||
SearchArchive((IArchiveFile)openedFile, ref layoutFile);
|
||||
else if (openedFile is BFLYT)
|
||||
try
|
||||
{
|
||||
var openedFile = file.OpenFile();
|
||||
if (openedFile is IArchiveFile)
|
||||
SearchArchive((IArchiveFile)openedFile, ref layoutFile);
|
||||
else if (openedFile is BFLYT)
|
||||
{
|
||||
Console.WriteLine("Part found! " + file.FileName);
|
||||
|
||||
layoutFile = openedFile as BFLYT;
|
||||
layoutFile.IFileInfo = new IFileInfo();
|
||||
layoutFile.IFileInfo.ArchiveParent = layoutFile.IFileInfo.ArchiveParent;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Part found! " + file.FileName);
|
||||
|
||||
layoutFile = openedFile as BFLYT;
|
||||
layoutFile.IFileInfo = new IFileInfo();
|
||||
layoutFile.IFileInfo.ArchiveParent = layoutFile.IFileInfo.ArchiveParent;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2148,54 +2148,69 @@ namespace LayoutBXLYT
|
||||
public int TopPoint;
|
||||
public int BottomPoint;
|
||||
|
||||
public OpenTK.Vector2 TopLeftPoint;
|
||||
public OpenTK.Vector2 TopRightPoint;
|
||||
public OpenTK.Vector2 BottomLeftPoint;
|
||||
public OpenTK.Vector2 BottomRightPoint;
|
||||
|
||||
public CustomRectangle(OpenTK.Vector2 topLeft, OpenTK.Vector2 topRight,
|
||||
OpenTK.Vector2 bottomLeft, OpenTK.Vector2 bottomRight)
|
||||
{
|
||||
TopLeftPoint = topLeft;
|
||||
TopRightPoint = topRight;
|
||||
BottomLeftPoint = bottomLeft;
|
||||
BottomRightPoint = bottomRight;
|
||||
|
||||
LeftPoint = (int)topLeft.X;
|
||||
RightPoint = (int)topRight.X;
|
||||
TopPoint = (int)topLeft.Y;
|
||||
BottomPoint = (int)bottomRight.Y;
|
||||
}
|
||||
|
||||
public CustomRectangle(int left, int right, int top, int bottom)
|
||||
{
|
||||
LeftPoint = left;
|
||||
RightPoint = right;
|
||||
TopPoint = top;
|
||||
BottomPoint = bottom;
|
||||
|
||||
TopLeftPoint = new OpenTK.Vector2(left,top);
|
||||
TopRightPoint = new OpenTK.Vector2(right, top);
|
||||
BottomLeftPoint = new OpenTK.Vector2(left, bottom);
|
||||
BottomRightPoint = new OpenTK.Vector2(right, bottom);
|
||||
}
|
||||
|
||||
public CustomRectangle RotateZ(float rotate)
|
||||
{
|
||||
var topLeft = RotateZPoint(LeftPoint, TopPoint, rotate);
|
||||
var bottomRight = RotateZPoint(RightPoint, BottomPoint, rotate);
|
||||
var topLeft = RotateZPoint(TopLeftPoint.X, TopLeftPoint.Y, rotate).Xy;
|
||||
var topRight = RotateZPoint(TopRightPoint.X, TopRightPoint.Y, rotate).Xy;
|
||||
var bottomLeft = RotateZPoint(BottomLeftPoint.X, BottomLeftPoint.Y, rotate).Xy;
|
||||
var bottomRight = RotateZPoint(BottomRightPoint.X, BottomRightPoint.Y, rotate).Xy;
|
||||
|
||||
return new CustomRectangle(
|
||||
(int)topLeft.X,
|
||||
(int)bottomRight.X,
|
||||
(int)topLeft.Y,
|
||||
(int)bottomRight.Y);
|
||||
topLeft,
|
||||
topRight,
|
||||
bottomLeft,
|
||||
bottomRight);
|
||||
}
|
||||
|
||||
private OpenTK.Vector2 RotateZPoint(float p1, float p2, float rotate)
|
||||
private OpenTK.Vector3 RotateZPoint(float p1, float p2, float rotate)
|
||||
{
|
||||
double angleInRadians = rotate * (Math.PI / 180);
|
||||
double cosTheta = Math.Cos(angleInRadians);
|
||||
double sinTheta = Math.Sin(angleInRadians);
|
||||
var centerPoint = new OpenTK.Vector2(0,0);
|
||||
|
||||
return new OpenTK.Vector2(
|
||||
(int)(p1 * cosTheta - p2 * sinTheta),
|
||||
(int)(p1 * sinTheta + p2 * cosTheta));
|
||||
|
||||
return new OpenTK.Vector2(
|
||||
(int)
|
||||
(cosTheta * (p1 - centerPoint.X) -
|
||||
sinTheta * (p2 - centerPoint.Y) + centerPoint.X),
|
||||
(int)
|
||||
(sinTheta * (p1 - centerPoint.X) +
|
||||
cosTheta * (p2 - centerPoint.Y) + centerPoint.Y));
|
||||
var rotatioZ = OpenTK.Matrix4.CreateRotationZ(OpenTK.MathHelper.DegreesToRadians(rotate));
|
||||
return OpenTK.Vector3.TransformPosition(new OpenTK.Vector3(p1, p2, 0), rotatioZ);
|
||||
}
|
||||
|
||||
public CustomRectangle GetTransformedRectangle(BasePane parent, Vector3F Transform, Vector3F Rotate, Vector2F scale)
|
||||
{
|
||||
var sca = new OpenTK.Vector2(scale.X, scale.Y);
|
||||
var pos = new OpenTK.Vector2(Transform.X, Transform.Y);
|
||||
|
||||
var rect = this.RotateZ(Rotate.Z);
|
||||
rect = new CustomRectangle(
|
||||
(int)(((rect.LeftPoint * scale.X) + Transform.X)),
|
||||
(int)(((rect.RightPoint * scale.X) + Transform.X)),
|
||||
(int)(((rect.TopPoint * scale.Y) + Transform.Y)),
|
||||
(int)(((rect.BottomPoint * scale.Y) + Transform.Y)));
|
||||
(rect.TopLeftPoint * sca) + pos,
|
||||
(rect.TopRightPoint * sca) + pos,
|
||||
(rect.BottomLeftPoint * sca) + pos,
|
||||
(rect.BottomRightPoint * sca) + pos);
|
||||
|
||||
if (parent != null)
|
||||
return parent.TransformParent(rect);
|
||||
|
@ -597,7 +597,7 @@ namespace FirstPlugin
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = FileFilters.GetFilter(typeof(TextureData));
|
||||
|
||||
ofd.DefaultExt = "bftex";
|
||||
ofd.DefaultExt = "png";
|
||||
ofd.Multiselect = true;
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
|
@ -214,6 +214,12 @@
|
||||
<Compile Include="FileFormats\Archives\DAT_Bayonetta.cs" />
|
||||
<Compile Include="FileFormats\Archives\GFA.cs" />
|
||||
<Compile Include="FileFormats\Archives\LM2\LM2_Material.cs" />
|
||||
<Compile Include="FileFormats\Archives\LM3\LM3_ChunkTable.cs" />
|
||||
<Compile Include="FileFormats\Archives\LM3\LM3_DICT.cs" />
|
||||
<Compile Include="FileFormats\Archives\LM3\LM3_Enums.cs" />
|
||||
<Compile Include="FileFormats\Archives\LM3\LM3_Material.cs" />
|
||||
<Compile Include="FileFormats\Archives\LM3\LM3_Model.cs" />
|
||||
<Compile Include="FileFormats\Archives\LM3\TexturePOWE.cs" />
|
||||
<Compile Include="FileFormats\Archives\PKZ.cs" />
|
||||
<Compile Include="FileFormats\Archives\VIBS.cs" />
|
||||
<Compile Include="FileFormats\Audio\Archives\AudioCommon.cs" />
|
||||
@ -355,6 +361,7 @@
|
||||
<Compile Include="GL\LM2_Render.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\BflytShader.cs" />
|
||||
<Compile Include="GL\Custom2D\KCLRendering2D.cs" />
|
||||
<Compile Include="GL\LM3_Renderer.cs" />
|
||||
<Compile Include="GUI\BFLYT\Animations\Basic\AddAnimGroupDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -667,9 +674,15 @@
|
||||
<Compile Include="GUI\BFRES\SmoothNormalsMultiMeshForm.Designer.cs">
|
||||
<DependentUpon>SmoothNormalsMultiMeshForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GUI\Byaml\MuuntEditor\Interfaces\IdrawableContainer.cs" />
|
||||
<Compile Include="GUI\Byaml\MuuntEditor\Interfaces\I2DDrawableContainer.cs" />
|
||||
<Compile Include="GUI\Byaml\MuuntEditor\Interfaces\I3DDrawableContainer.cs" />
|
||||
<Compile Include="GUI\Byaml\MuuntEditor\Interfaces\IDrawableObject.cs" />
|
||||
<Compile Include="GUI\Byaml\MuuntEditor\Interfaces\IMuuntLoader.cs" />
|
||||
<Compile Include="GUI\Byaml\MuuntEditor\MuuntCollisionObject.cs" />
|
||||
<Compile Include="GUI\Byaml\MuuntEditor\MuuntEditor3D.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GUI\Byaml\MuuntEditor\Plugins\MK8\PathDoublePointDrawableContainer.cs" />
|
||||
<Compile Include="GUI\Byaml\MuuntEditor\Plugins\MK8\PathDrawableContainer.cs" />
|
||||
<Compile Include="GUI\Byaml\MuuntEditor\PropertyObject.cs" />
|
||||
<Compile Include="GUI\Byaml\MuuntEditor\MapObject.cs" />
|
||||
@ -700,10 +713,10 @@
|
||||
</Compile>
|
||||
<Compile Include="GUI\Byaml\MuuntEditor\Plugins\MK8\TrackMuuntLoader.cs" />
|
||||
<Compile Include="GUI\Byaml\MuuntEditor\PropertyGridConverters.cs" />
|
||||
<Compile Include="GUI\Byaml\TurboCourseMuunt\RenderableDoublePointPath.cs" />
|
||||
<Compile Include="GUI\Byaml\TurboCourseMuunt\RenderablePath.cs" />
|
||||
<Compile Include="GUI\Editors\MK8TrackEditor\MapCameraViewer.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GUI\Byaml\TurboCourseMuunt\TransformableObject.cs" />
|
||||
<Compile Include="GUI\Editors\MK8TrackEditor\MapCameraViewer.cs" />
|
||||
<Compile Include="GUI\Editors\PTCL\Color8KeySlider.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
@ -1900,5 +1913,8 @@
|
||||
<ItemGroup>
|
||||
<None Include="Resources\MissingTexture.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\Hashes\LM3_Hashes.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -5,19 +5,142 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using Toolbox.Library;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
public class KCLRendering2D
|
||||
{
|
||||
// gl buffer objects
|
||||
int vbo_position;
|
||||
int ibo_elements;
|
||||
|
||||
public List<KCL.KCLModel> models = new List<KCL.KCLModel>();
|
||||
|
||||
private GLShaderGeneric Shader;
|
||||
|
||||
public KCLRendering2D(KCL kcl)
|
||||
{
|
||||
string vertPath = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Drawing2D", "KCL.vert");
|
||||
string fragPath = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Drawing2D", "KCL.frag");
|
||||
|
||||
Shader = new GLShaderGeneric();
|
||||
Shader.VertexShader = System.IO.File.ReadAllText(vertPath);
|
||||
Shader.FragmentShader = System.IO.File.ReadAllText(fragPath);
|
||||
Shader.Compile();
|
||||
|
||||
models = kcl.GetKclModels();
|
||||
}
|
||||
|
||||
private void GenerateBuffers()
|
||||
{
|
||||
GL.GenBuffers(1, out vbo_position);
|
||||
GL.GenBuffers(1, out ibo_elements);
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
GL.DeleteBuffer(vbo_position);
|
||||
GL.DeleteBuffer(ibo_elements);
|
||||
}
|
||||
|
||||
public void UpdateVertexData()
|
||||
{
|
||||
if (!Runtime.OpenTKInitialized)
|
||||
return;
|
||||
|
||||
KCL.DisplayVertex[] Vertices;
|
||||
int[] Faces;
|
||||
|
||||
int poffset = 0;
|
||||
int voffset = 0;
|
||||
List<KCL.DisplayVertex> Vs = new List<KCL.DisplayVertex>();
|
||||
List<int> Ds = new List<int>();
|
||||
foreach (KCL.KCLModel m in models)
|
||||
{
|
||||
m.Offset = poffset * 4;
|
||||
List<KCL.DisplayVertex> pv = m.CreateDisplayVertices();
|
||||
Vs.AddRange(pv);
|
||||
|
||||
for (int i = 0; i < m.displayFaceSize; i++)
|
||||
{
|
||||
Ds.Add(m.display[i] + voffset);
|
||||
}
|
||||
poffset += m.displayFaceSize;
|
||||
voffset += pv.Count;
|
||||
}
|
||||
|
||||
// Binds
|
||||
Vertices = Vs.ToArray();
|
||||
Faces = Ds.ToArray();
|
||||
|
||||
// Bind only once!
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
|
||||
GL.BufferData<KCL.DisplayVertex>(BufferTarget.ArrayBuffer, (IntPtr)(Vertices.Length * KCL.DisplayVertex.Size), Vertices, BufferUsageHint.StaticDraw);
|
||||
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
|
||||
GL.BufferData<int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw);
|
||||
|
||||
LibraryGUI.UpdateViewport();
|
||||
}
|
||||
|
||||
private void CheckBuffers()
|
||||
{
|
||||
if (!Runtime.OpenTKInitialized)
|
||||
return;
|
||||
|
||||
bool buffersWereInitialized = ibo_elements != 0 && vbo_position != 0;
|
||||
if (!buffersWereInitialized)
|
||||
{
|
||||
GenerateBuffers();
|
||||
UpdateVertexData();
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(Matrix4 modelViewMatrix)
|
||||
{
|
||||
CheckBuffers();
|
||||
|
||||
if (!Runtime.OpenTKInitialized)
|
||||
return;
|
||||
|
||||
GL.Disable(EnableCap.CullFace);
|
||||
|
||||
Shader.Enable();
|
||||
Shader.SetMatrix("modelViewMatrix", ref modelViewMatrix);
|
||||
Shader.EnableVertexAttributes();
|
||||
foreach (KCL.KCLModel mdl in models)
|
||||
DrawModel(mdl);
|
||||
|
||||
Shader.DisableVertexAttributes();
|
||||
|
||||
GL.UseProgram(0);
|
||||
GL.Disable(EnableCap.DepthTest);
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
GL.Enable(EnableCap.CullFace);
|
||||
}
|
||||
|
||||
private void DrawModel(KCL.KCLModel m, bool drawSelection = false)
|
||||
{
|
||||
if (m.faces.Count <= 3)
|
||||
return;
|
||||
|
||||
SetVertexAttributes(m);
|
||||
|
||||
if (Runtime.RenderModels)
|
||||
{
|
||||
GL.DrawElements(PrimitiveType.Triangles, m.displayFaceSize, DrawElementsType.UnsignedInt, m.Offset);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetVertexAttributes(KCL.KCLModel m)
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
|
||||
GL.VertexAttribPointer(Shader.GetAttribute("vPosition"), 3, VertexAttribPointerType.Float, false, KCL.DisplayVertex.Size, 0);
|
||||
GL.VertexAttribPointer(Shader.GetAttribute("vNormal"), 3, VertexAttribPointerType.Float, false, KCL.DisplayVertex.Size, 12);
|
||||
GL.VertexAttribPointer(Shader.GetAttribute("vColor"), 3, VertexAttribPointerType.Float, false, KCL.DisplayVertex.Size, 24);
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ namespace FirstPlugin
|
||||
}
|
||||
public override void Draw(GL_ControlLegacy control, Pass pass)
|
||||
{
|
||||
if (!Runtime.OpenTKInitialized)
|
||||
if (!Runtime.OpenTKInitialized || defaultShaderProgram == null)
|
||||
return;
|
||||
|
||||
Matrix4 mvpMat = control.ModelMatrix * control.CameraMatrix * control.ProjectionMatrix;
|
||||
@ -245,7 +245,7 @@ namespace FirstPlugin
|
||||
{
|
||||
CheckBuffers();
|
||||
|
||||
if (!Runtime.OpenTKInitialized || pass == Pass.TRANSPARENT)
|
||||
if (!Runtime.OpenTKInitialized || pass == Pass.TRANSPARENT || defaultShaderProgram == null)
|
||||
return;
|
||||
|
||||
Matrix4 camMat = control.ModelMatrix * control.CameraMatrix * control.ProjectionMatrix;
|
||||
|
@ -69,17 +69,31 @@ namespace LayoutBXLYT
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (windowFrameSelector1.SelectedFrame)
|
||||
if (windowFrameSelector1.FrameCount == 4)
|
||||
{
|
||||
case FrameSelect.TopLeft: return pane.WindowFrames[0];
|
||||
case FrameSelect.TopRight: return pane.WindowFrames[1];
|
||||
case FrameSelect.BottomLeft: return pane.WindowFrames[2];
|
||||
case FrameSelect.BottomRight: return pane.WindowFrames[3];
|
||||
case FrameSelect.Top: return pane.WindowFrames[4];
|
||||
case FrameSelect.Bottom: return pane.WindowFrames[5];
|
||||
case FrameSelect.Left: return pane.WindowFrames[6];
|
||||
case FrameSelect.Right: return pane.WindowFrames[7];
|
||||
default: return null;
|
||||
switch (windowFrameSelector1.SelectedFrame)
|
||||
{
|
||||
case FrameSelect.TopLeft: return pane.WindowFrames[0];
|
||||
case FrameSelect.TopRight: return pane.WindowFrames[1];
|
||||
case FrameSelect.BottomLeft: return pane.WindowFrames[2];
|
||||
case FrameSelect.BottomRight: return pane.WindowFrames[3];
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (windowFrameSelector1.SelectedFrame)
|
||||
{
|
||||
case FrameSelect.TopLeft: return pane.WindowFrames[0];
|
||||
case FrameSelect.TopRight: return pane.WindowFrames[1];
|
||||
case FrameSelect.BottomLeft: return pane.WindowFrames[2];
|
||||
case FrameSelect.BottomRight: return pane.WindowFrames[3];
|
||||
case FrameSelect.Left: return pane.WindowFrames[4];
|
||||
case FrameSelect.Right: return pane.WindowFrames[5];
|
||||
case FrameSelect.Top: return pane.WindowFrames[6];
|
||||
case FrameSelect.Bottom: return pane.WindowFrames[7];
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -365,8 +365,46 @@ namespace LayoutBXLYT
|
||||
}
|
||||
}
|
||||
|
||||
#region NodeDragDrop
|
||||
|
||||
private string NodeMap;
|
||||
|
||||
private void treeView1_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(PaneTreeWrapper)))
|
||||
{
|
||||
Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y));
|
||||
TreeNode NodeOver = treeView1.GetNodeAt(targetPoint);
|
||||
TreeNode NodeMoving = (PaneTreeWrapper)e.Data.GetData(typeof(PaneTreeWrapper));
|
||||
|
||||
if (NodeOver != null && (NodeOver != NodeMoving || (NodeOver.Parent != null && NodeOver.Index == (NodeOver.Parent.Nodes.Count - 1))))
|
||||
{
|
||||
int OffsetY = this.treeView1.PointToClient(Cursor.Position).Y - NodeOver.Bounds.Top;
|
||||
int NodeOverImageWidth = this.treeView1.ImageList.Images[NodeOver.ImageIndex].Size.Width + 8;
|
||||
Graphics g = this.treeView1.CreateGraphics();
|
||||
|
||||
//Folder node
|
||||
|
||||
if (OffsetY < (NodeOver.Bounds.Height / 3))
|
||||
{
|
||||
TreeNode tnParadox = NodeOver;
|
||||
while (tnParadox.Parent != null)
|
||||
{
|
||||
if (tnParadox.Parent == NodeMoving)
|
||||
{
|
||||
this.NodeMap = "";
|
||||
return;
|
||||
}
|
||||
|
||||
tnParadox = tnParadox.Parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/*
|
||||
if (e.Data.GetDataPresent(typeof(PaneTreeWrapper)))
|
||||
{
|
||||
Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y));
|
||||
@ -374,9 +412,6 @@ namespace LayoutBXLYT
|
||||
TreeNode targetNode = treeView1.GetNodeAt(targetPoint);
|
||||
TreeNode draggedNode = (PaneTreeWrapper)e.Data.GetData(typeof(PaneTreeWrapper));
|
||||
|
||||
Console.WriteLine("draggedPane " + draggedNode.Text);
|
||||
Console.WriteLine("draggedPane is pane? " + (draggedNode.Tag is BasePane));
|
||||
|
||||
var draggedPane = draggedNode.Tag as BasePane;
|
||||
if (draggedPane == null || draggedPane.IsRoot)
|
||||
return;
|
||||
@ -432,7 +467,7 @@ namespace LayoutBXLYT
|
||||
|
||||
ParentEditor.UpdateViewport();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private void treeView1_DragEnter(object sender, DragEventArgs e)
|
||||
|
@ -249,10 +249,10 @@ namespace LayoutBXLYT
|
||||
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.Color4(Color.FromArgb(128, 255, 0, 0));
|
||||
GL.Vertex2(hitbox.LeftPoint, hitbox.BottomPoint);
|
||||
GL.Vertex2(hitbox.RightPoint, hitbox.BottomPoint);
|
||||
GL.Vertex2(hitbox.RightPoint, hitbox.TopPoint);
|
||||
GL.Vertex2(hitbox.LeftPoint, hitbox.TopPoint);
|
||||
GL.Vertex2(hitbox.BottomLeftPoint);
|
||||
GL.Vertex2(hitbox.BottomRightPoint);
|
||||
GL.Vertex2(hitbox.TopRightPoint);
|
||||
GL.Vertex2(hitbox.TopLeftPoint);
|
||||
GL.End();
|
||||
}
|
||||
}
|
||||
@ -300,10 +300,10 @@ namespace LayoutBXLYT
|
||||
{
|
||||
GL.Begin(PrimitiveType.LineLoop);
|
||||
GL.Color4(Color.Red);
|
||||
GL.Vertex2(SelectionBox.LeftPoint, SelectionBox.BottomPoint);
|
||||
GL.Vertex2(SelectionBox.RightPoint, SelectionBox.BottomPoint);
|
||||
GL.Vertex2(SelectionBox.RightPoint, SelectionBox.TopPoint);
|
||||
GL.Vertex2(SelectionBox.LeftPoint, SelectionBox.TopPoint);
|
||||
GL.Vertex2(SelectionBox.BottomLeftPoint);
|
||||
GL.Vertex2(SelectionBox.BottomRightPoint);
|
||||
GL.Vertex2(SelectionBox.TopRightPoint);
|
||||
GL.Vertex2(SelectionBox.TopLeftPoint);
|
||||
GL.End();
|
||||
}
|
||||
|
||||
@ -333,10 +333,10 @@ namespace LayoutBXLYT
|
||||
pane.GetTranslation(), pane.GetRotation(), pane.GetScale());
|
||||
points.AddRange(new Vector2[4]
|
||||
{
|
||||
new Vector2(rect.LeftPoint, rect.TopPoint),
|
||||
new Vector2(rect.RightPoint, rect.TopPoint),
|
||||
new Vector2(rect.RightPoint, rect.BottomPoint),
|
||||
new Vector2(rect.LeftPoint, rect.BottomPoint)
|
||||
rect.TopLeftPoint,
|
||||
rect.TopRightPoint,
|
||||
rect.BottomRightPoint,
|
||||
rect.BottomLeftPoint,
|
||||
});
|
||||
|
||||
var minX = (int)points.Min(p => p.X);
|
||||
@ -363,10 +363,10 @@ namespace LayoutBXLYT
|
||||
|
||||
GL.Begin(PrimitiveType.LineLoop);
|
||||
GL.Color4(isSelected ? Color.Red : Color.Green);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.BottomLeftPoint);
|
||||
GL.Vertex2(rect.BottomRightPoint);
|
||||
GL.Vertex2(rect.TopRightPoint);
|
||||
GL.Vertex2(rect.TopLeftPoint);
|
||||
GL.End();
|
||||
|
||||
if (isSelected)
|
||||
@ -525,10 +525,10 @@ namespace LayoutBXLYT
|
||||
//Draw a quad which is the backcolor but lighter
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.Color3(BackgroundColor.Lighten(10));
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.TopLeftPoint);
|
||||
GL.Vertex2(rect.TopRightPoint);
|
||||
GL.Vertex2(rect.BottomRightPoint);
|
||||
GL.Vertex2(rect.BottomLeftPoint);
|
||||
GL.End();
|
||||
|
||||
//Draw outline of root pane
|
||||
@ -536,10 +536,10 @@ namespace LayoutBXLYT
|
||||
GL.PolygonOffset(0.5f, 2);
|
||||
GL.LineWidth(33);
|
||||
GL.Color3(color);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.TopLeftPoint);
|
||||
GL.Vertex2(rect.TopRightPoint);
|
||||
GL.Vertex2(rect.BottomRightPoint);
|
||||
GL.Vertex2(rect.BottomLeftPoint);
|
||||
GL.End();
|
||||
}
|
||||
|
||||
@ -839,6 +839,7 @@ namespace LayoutBXLYT
|
||||
stContextMenuStrip1.Items.Clear();
|
||||
stContextMenuStrip1.Items.Add(createPanes);
|
||||
stContextMenuStrip1.Items.Add(selectOverlapping);
|
||||
stContextMenuStrip1.Items.Add(new STToolStripItem("Show All Hidden Panes", ShowAllPaneAction));
|
||||
|
||||
if (SelectedPanes.Count > 0)
|
||||
{
|
||||
@ -848,7 +849,6 @@ namespace LayoutBXLYT
|
||||
stContextMenuStrip1.Items.Add(new STToolStripItem("Edit Group"));
|
||||
stContextMenuStrip1.Items.Add(new STToolStripItem("Delete Selected Panes",DeletePaneAction ));
|
||||
stContextMenuStrip1.Items.Add(new STToolStripItem("Hide Selected Panes", HidePaneAction));
|
||||
stContextMenuStrip1.Items.Add(new STToolStripItem("Show All Hidden Panes", ShowAllPaneAction));
|
||||
}
|
||||
|
||||
stContextMenuStrip1.Show(Cursor.Position);
|
||||
@ -943,6 +943,7 @@ namespace LayoutBXLYT
|
||||
{
|
||||
UndoManger.AddToUndo(new LayoutUndoManager.UndoActionPaneHide(SelectedPanes));
|
||||
ParentEditor?.UpdateHiearchyTree();
|
||||
SelectedPanes.Clear();
|
||||
glControl1.Invalidate();
|
||||
}
|
||||
|
||||
@ -1260,6 +1261,47 @@ namespace LayoutBXLYT
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pickAction == PickAction.Scale)
|
||||
{
|
||||
foreach (var pane in SelectedPanes)
|
||||
{
|
||||
if (pickOriginMouse != Point.Empty)
|
||||
{
|
||||
float scaX = pane.Scale.X;
|
||||
float scaY = pane.Scale.Y;
|
||||
|
||||
if (pickAxis == PickAxis.X)
|
||||
scaX = pane.Scale.X - pickMouse.X;
|
||||
if (pickAxis == PickAxis.Y)
|
||||
scaY = pane.Scale.Y - pickMouse.Y;
|
||||
if (pickAxis == PickAxis.All)
|
||||
{
|
||||
scaX = pane.Scale.X - pickMouse.X;
|
||||
scaY = pane.Scale.Y - pickMouse.Y;
|
||||
}
|
||||
|
||||
if (Runtime.LayoutEditor.AnimationEditMode)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (snapToGrid)
|
||||
{
|
||||
int gridCubeWidth = 16, gridCubeHeight = 16;
|
||||
|
||||
pane.Scale = new Syroot.Maths.Vector2F(
|
||||
(float)(Math.Round(scaX / gridCubeWidth) * gridCubeWidth),
|
||||
(float)(Math.Round(scaY / gridCubeHeight) * gridCubeHeight));
|
||||
}
|
||||
else
|
||||
{
|
||||
pane.Scale = new Syroot.Maths.Vector2F(scaX, scaY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!showSelectionBox)
|
||||
{
|
||||
var selectionBox = GetSelectedPanesBounding(SelectedPanes);
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FirstPlugin.MuuntEditor
|
||||
{
|
||||
public interface IDrawableContainer
|
||||
public interface I2DDrawableContainer
|
||||
{
|
||||
IDrawableObject Drawable { get; }
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
|
||||
namespace FirstPlugin.MuuntEditor
|
||||
{
|
||||
public interface I3DDrawableContainer
|
||||
{
|
||||
List<AbstractGlDrawable> Drawables { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FirstPlugin;
|
||||
|
||||
namespace FirstPlugin.MuuntEditor
|
||||
{
|
||||
public class MuuntCollisionObject
|
||||
{
|
||||
public KCL CollisionFile;
|
||||
public KCLRendering2D Renderer;
|
||||
}
|
||||
}
|
@ -39,6 +39,7 @@
|
||||
this.toggle3DViewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.stToolStrip1 = new Toolbox.Library.Forms.STToolStrip();
|
||||
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
|
||||
this.loadCollisionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.stMenuStrip1.SuspendLayout();
|
||||
this.stToolStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -70,6 +71,7 @@
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.openToolStripMenuItem,
|
||||
this.loadCollisionToolStripMenuItem,
|
||||
this.saveToolStripMenuItem,
|
||||
this.saveAsToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
@ -79,19 +81,19 @@
|
||||
// openToolStripMenuItem
|
||||
//
|
||||
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
|
||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
|
||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.openToolStripMenuItem.Text = "Open";
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.saveToolStripMenuItem.Text = "Save";
|
||||
//
|
||||
// saveAsToolStripMenuItem
|
||||
//
|
||||
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
|
||||
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
|
||||
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.saveAsToolStripMenuItem.Text = "Save As";
|
||||
//
|
||||
// editToolStripMenuItem
|
||||
@ -133,6 +135,14 @@
|
||||
this.toolStripButton1.Name = "toolStripButton1";
|
||||
this.toolStripButton1.Size = new System.Drawing.Size(23, 22);
|
||||
this.toolStripButton1.Text = "toolStripButton1";
|
||||
this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
|
||||
//
|
||||
// loadCollisionToolStripMenuItem
|
||||
//
|
||||
this.loadCollisionToolStripMenuItem.Name = "loadCollisionToolStripMenuItem";
|
||||
this.loadCollisionToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.loadCollisionToolStripMenuItem.Text = "Load Collision";
|
||||
this.loadCollisionToolStripMenuItem.Click += new System.EventHandler(this.loadCollisionToolStripMenuItem_Click);
|
||||
//
|
||||
// MuuntEditor
|
||||
//
|
||||
@ -168,5 +178,6 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem toggle3DViewToolStripMenuItem;
|
||||
private Toolbox.Library.Forms.STToolStrip stToolStrip1;
|
||||
private System.Windows.Forms.ToolStripButton toolStripButton1;
|
||||
private System.Windows.Forms.ToolStripMenuItem loadCollisionToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -10,11 +10,15 @@ using System.Windows.Forms;
|
||||
using Toolbox.Library.Forms;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using FirstPlugin;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.IO;
|
||||
|
||||
namespace FirstPlugin.MuuntEditor
|
||||
{
|
||||
public partial class MuuntEditor : Form
|
||||
{
|
||||
public List<MuuntCollisionObject> CollisionObjects = new List<MuuntCollisionObject>();
|
||||
|
||||
public List<ObjectGroup> Groups = new List<ObjectGroup>();
|
||||
public EventHandler ObjectSelected;
|
||||
|
||||
@ -22,6 +26,9 @@ namespace FirstPlugin.MuuntEditor
|
||||
|
||||
private dynamic ActiveByml;
|
||||
|
||||
private DockContent ViewportDock;
|
||||
|
||||
private MuuntEditor3D Viewport3D;
|
||||
private MuuntEditor2D Viewport2D;
|
||||
private MuuntObjectList ObjectList;
|
||||
private MuuntPropertiesEditor PropertiesEditor;
|
||||
@ -70,13 +77,13 @@ namespace FirstPlugin.MuuntEditor
|
||||
|
||||
private void LoadViewport()
|
||||
{
|
||||
DockContent dockContent = new DockContent();
|
||||
ViewportDock = new DockContent();
|
||||
Viewport2D = new MuuntEditor2D(this);
|
||||
Viewport2D.Dock = DockStyle.Fill;
|
||||
dockContent.Controls.Add(Viewport2D);
|
||||
ViewportDock.Controls.Add(Viewport2D);
|
||||
|
||||
dockContent.Show(dockPanel1, DockState.Document);
|
||||
dockContent.DockHandler.AllowEndUserDocking = false;
|
||||
ViewportDock.Show(dockPanel1, DockState.Document);
|
||||
ViewportDock.DockHandler.AllowEndUserDocking = false;
|
||||
}
|
||||
|
||||
private void ShowObjectList()
|
||||
@ -95,15 +102,91 @@ namespace FirstPlugin.MuuntEditor
|
||||
return;
|
||||
|
||||
PropertiesEditor = new MuuntPropertiesEditor(this);
|
||||
PropertiesEditor.ProperyChanged += OnPropertyChanged;
|
||||
|
||||
if (ObjectList != null)
|
||||
PropertiesEditor.Show(ObjectList.Pane, DockAlignment.Bottom, 0.5);
|
||||
PropertiesEditor.Show(dockPanel1, DockState.DockLeft);
|
||||
}
|
||||
|
||||
private void OnPropertyChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Viewport2D != null)
|
||||
Viewport2D.UpdateViewport();
|
||||
if (Viewport3D != null)
|
||||
Viewport3D.UpdateViewport();
|
||||
}
|
||||
|
||||
private void OnObjectSelected(object sender, EventArgs e)
|
||||
{
|
||||
if (e is TreeViewEventArgs)
|
||||
{
|
||||
var node = ((TreeViewEventArgs)e).Node;
|
||||
if (node.Tag != null && PropertiesEditor != null)
|
||||
{
|
||||
PropertiesEditor.LoadProperty(node.Tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void toolStripButton1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Runtime.MuuntEditor.Enable3DViewport)
|
||||
{
|
||||
Runtime.MuuntEditor.Enable3DViewport = false;
|
||||
toolStripButton1.Image = Properties.Resources.ViewportIconDisable;
|
||||
}
|
||||
else
|
||||
{
|
||||
toolStripButton1.Image = Properties.Resources.ViewportIcon;
|
||||
Runtime.MuuntEditor.Enable3DViewport = true;
|
||||
}
|
||||
|
||||
if (ViewportDock != null)
|
||||
{
|
||||
ViewportDock.Controls.Clear();
|
||||
if (Runtime.MuuntEditor.Enable3DViewport)
|
||||
{
|
||||
if (Viewport3D == null)
|
||||
{
|
||||
Viewport3D = new MuuntEditor3D(this);
|
||||
Viewport3D.Dock = DockStyle.Fill;
|
||||
}
|
||||
ViewportDock.Controls.Add(Viewport3D);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Viewport2D == null)
|
||||
{
|
||||
Viewport2D = new MuuntEditor2D(this);
|
||||
Viewport2D.Dock = DockStyle.Fill;
|
||||
}
|
||||
ViewportDock.Controls.Add(Viewport2D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadCollisionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Viewport2D == null && Viewport3D == null) return;
|
||||
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = Utils.GetAllFilters(typeof(KCL));
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var fileFormat = STFileLoader.OpenFileFormat(ofd.FileName);
|
||||
if (fileFormat != null && fileFormat is KCL)
|
||||
LoadCollision((KCL)fileFormat);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadCollision(KCL kcl)
|
||||
{
|
||||
MuuntCollisionObject col = new MuuntCollisionObject();
|
||||
col.CollisionFile = kcl;
|
||||
col.Renderer = new KCLRendering2D(kcl);
|
||||
Viewport3D?.AddDrawable(kcl.DrawableContainer.Drawables[0]);
|
||||
CollisionObjects.Add(col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,32 +21,45 @@ namespace FirstPlugin.MuuntEditor
|
||||
|
||||
public override void RenderSceme()
|
||||
{
|
||||
foreach (var col in ParentEditor.CollisionObjects)
|
||||
col.Renderer.Draw(Camera.ModelViewMatrix);
|
||||
|
||||
foreach (var group in ParentEditor.Groups)
|
||||
{
|
||||
if (group is IDrawableContainer)
|
||||
((IDrawableContainer)group).Drawable?.Draw(Camera.ModelMatrix);
|
||||
foreach (var subProp in group.Objects)
|
||||
RenderGroupChildren(subProp);
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderGroupChildren(PropertyObject propertyObject)
|
||||
{
|
||||
if (propertyObject is I2DDrawableContainer)
|
||||
((I2DDrawableContainer)propertyObject).Drawable?.Draw(Camera.ModelViewMatrix);
|
||||
|
||||
foreach (var subProperty in propertyObject.SubObjects)
|
||||
RenderGroupChildren(subProperty);
|
||||
}
|
||||
|
||||
public override List<IPickable2DObject> GetPickableObjects()
|
||||
{
|
||||
List<IPickable2DObject> picks = new List<IPickable2DObject>();
|
||||
foreach (var group in ParentEditor.Groups)
|
||||
{
|
||||
foreach (var obj in group.Objects)
|
||||
{
|
||||
if (obj is IPickable2DObject)
|
||||
picks.Add((IPickable2DObject)obj);
|
||||
|
||||
foreach (var subobj in obj.SubObjects)
|
||||
{
|
||||
if (subobj is IPickable2DObject)
|
||||
picks.Add((IPickable2DObject)subobj);
|
||||
}
|
||||
}
|
||||
GetPickableSubObjects(obj, picks);
|
||||
}
|
||||
|
||||
return picks;
|
||||
}
|
||||
|
||||
private void GetPickableSubObjects(PropertyObject prob, List<IPickable2DObject> picks)
|
||||
{
|
||||
if (prob is IPickable2DObject)
|
||||
picks.Add((IPickable2DObject)prob);
|
||||
|
||||
|
||||
foreach (var subobj in prob.SubObjects)
|
||||
GetPickableSubObjects(subobj, picks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
118
File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditor3D.cs
Normal file
118
File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditor3D.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GL_EditorFramework.GL_Core;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.Forms;
|
||||
using Toolbox.Library.Rendering;
|
||||
using GL_EditorFramework.EditorDrawables;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using OpenTK;
|
||||
|
||||
namespace FirstPlugin.MuuntEditor
|
||||
{
|
||||
public class MuuntEditor3D : STUserControl
|
||||
{
|
||||
public MuuntEditor ParentEditor;
|
||||
|
||||
public GL_ControlBase gl_Control;
|
||||
|
||||
private EditorScene scene;
|
||||
private bool loaded = false;
|
||||
|
||||
public MuuntEditor3D(MuuntEditor muuntEditor)
|
||||
{
|
||||
ParentEditor = muuntEditor;
|
||||
|
||||
if (Runtime.UseLegacyGL)
|
||||
gl_Control = new GL_ControlLegacy();
|
||||
else
|
||||
gl_Control = new GL_ControlModern();
|
||||
|
||||
gl_Control.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
Controls.Add(gl_Control);
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
scene = new EditorScene();
|
||||
// LoadBaseDrawables();
|
||||
|
||||
scene.objects.Add(new TransformableObject(new Vector3(), Quaternion.Identity, new Vector3(1)));
|
||||
|
||||
foreach (var col in ParentEditor.CollisionObjects)
|
||||
AddDrawable(col.CollisionFile.DrawableContainer.Drawables[0]);
|
||||
|
||||
foreach (var group in ParentEditor.Groups)
|
||||
{
|
||||
foreach (var subProp in group.Objects)
|
||||
AddGroupChildren(subProp);
|
||||
}
|
||||
|
||||
gl_Control.MainDrawable = scene;
|
||||
gl_Control.ActiveCamera = new GL_EditorFramework.StandardCameras.InspectCamera(1f);
|
||||
gl_Control.ZFar = 100000;
|
||||
gl_Control.ZNear = 0.1f;
|
||||
gl_Control.CameraDistance = 20;
|
||||
scene.ObjectsMoved += Scene_ObjectsMoved;
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
private void Scene_ObjectsMoved(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void AddGroupChildren(PropertyObject propertyObject)
|
||||
{
|
||||
if (propertyObject is I3DDrawableContainer){
|
||||
foreach (var drawable in ((I3DDrawableContainer)propertyObject).Drawables)
|
||||
AddDrawable(drawable);
|
||||
}
|
||||
|
||||
foreach (var subProperty in propertyObject.SubObjects)
|
||||
AddGroupChildren(subProperty);
|
||||
}
|
||||
|
||||
public void AddDrawable(AbstractGlDrawable drawable)
|
||||
{
|
||||
Console.WriteLine($"drawable " + drawable);
|
||||
if (drawable is IEditableObject)
|
||||
scene.objects.Add((IEditableObject)drawable);
|
||||
else
|
||||
scene.staticObjects.Add(drawable);
|
||||
|
||||
if (loaded)
|
||||
UpdateScene();
|
||||
}
|
||||
|
||||
private void UpdateScene() {
|
||||
gl_Control.MainDrawable = scene;
|
||||
}
|
||||
|
||||
public void UpdateViewport()
|
||||
{
|
||||
gl_Control.Invalidate();
|
||||
}
|
||||
|
||||
private void LoadBaseDrawables()
|
||||
{
|
||||
Runtime.OpenTKInitialized = true;
|
||||
|
||||
var floor = new DrawableFloor();
|
||||
var xyzLnes = new DrawableXyzLines();
|
||||
var skybox = new DrawableSkybox();
|
||||
var background = new DrawableBackground();
|
||||
|
||||
scene.staticObjects.Add(floor);
|
||||
scene.staticObjects.Add(xyzLnes);
|
||||
scene.staticObjects.Add(skybox);
|
||||
scene.staticObjects.Add(background);
|
||||
}
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.stComboBox1 = new Toolbox.Library.Forms.STComboBox();
|
||||
this.listViewCustom1 = new Toolbox.Library.Forms.ListViewCustom();
|
||||
this.treeView1 = new System.Windows.Forms.TreeView();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// stComboBox1
|
||||
@ -43,27 +43,25 @@
|
||||
this.stComboBox1.Name = "stComboBox1";
|
||||
this.stComboBox1.Size = new System.Drawing.Size(257, 21);
|
||||
this.stComboBox1.TabIndex = 0;
|
||||
this.stComboBox1.SelectedIndexChanged += new System.EventHandler(this.stComboBox1_SelectedIndexChanged);
|
||||
//
|
||||
// listViewCustom1
|
||||
// treeView1
|
||||
//
|
||||
this.listViewCustom1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.listViewCustom1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.listViewCustom1.HideSelection = false;
|
||||
this.listViewCustom1.Location = new System.Drawing.Point(12, 39);
|
||||
this.listViewCustom1.Name = "listViewCustom1";
|
||||
this.listViewCustom1.OwnerDraw = true;
|
||||
this.listViewCustom1.Size = new System.Drawing.Size(257, 265);
|
||||
this.listViewCustom1.TabIndex = 1;
|
||||
this.listViewCustom1.UseCompatibleStateImageBehavior = false;
|
||||
this.treeView1.Location = new System.Drawing.Point(12, 39);
|
||||
this.treeView1.Name = "treeView1";
|
||||
this.treeView1.Size = new System.Drawing.Size(257, 274);
|
||||
this.treeView1.TabIndex = 1;
|
||||
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
|
||||
//
|
||||
// MuuntObjectList
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(281, 316);
|
||||
this.Controls.Add(this.listViewCustom1);
|
||||
this.Controls.Add(this.treeView1);
|
||||
this.Controls.Add(this.stComboBox1);
|
||||
this.Name = "MuuntObjectList";
|
||||
this.Text = "MuuntObjectList";
|
||||
@ -74,6 +72,6 @@
|
||||
#endregion
|
||||
|
||||
private Toolbox.Library.Forms.STComboBox stComboBox1;
|
||||
private Toolbox.Library.Forms.ListViewCustom listViewCustom1;
|
||||
private System.Windows.Forms.TreeView treeView1;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Toolbox.Library.Forms;
|
||||
|
||||
namespace FirstPlugin.MuuntEditor
|
||||
{
|
||||
@ -14,18 +15,63 @@ namespace FirstPlugin.MuuntEditor
|
||||
{
|
||||
private MuuntEditor ParentEditor;
|
||||
|
||||
private List<ObjectGroup> Groups;
|
||||
|
||||
public MuuntObjectList(MuuntEditor editor)
|
||||
{
|
||||
InitializeComponent();
|
||||
ParentEditor = editor;
|
||||
|
||||
treeView1.BackColor = FormThemes.BaseTheme.FormBackColor;
|
||||
treeView1.ForeColor = FormThemes.BaseTheme.FormForeColor;
|
||||
}
|
||||
|
||||
public void LoadObjects(List<ObjectGroup> groups)
|
||||
{
|
||||
Groups = groups;
|
||||
|
||||
stComboBox1.Items.Clear();
|
||||
for (int i = 0; i < groups.Count; i++)
|
||||
{
|
||||
stComboBox1.Items.Add(groups[i].Name);
|
||||
}
|
||||
}
|
||||
|
||||
private void stComboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
treeView1.Nodes.Clear();
|
||||
if (stComboBox1.SelectedIndex >= 0)
|
||||
{
|
||||
int index = stComboBox1.SelectedIndex;
|
||||
var group = Groups[index];
|
||||
|
||||
LoadPropertyObjects(group.Objects);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadPropertyObjects(List<PropertyObject> properties, TreeNode parent = null)
|
||||
{
|
||||
if (properties == null) return;
|
||||
|
||||
foreach (var prob in properties)
|
||||
{
|
||||
TreeNode nodeWrapper = new TreeNode(prob.Name);
|
||||
nodeWrapper.Name = prob.Name;
|
||||
nodeWrapper.Tag = prob;
|
||||
|
||||
if (parent == null)
|
||||
treeView1.Nodes.Add(nodeWrapper);
|
||||
else
|
||||
parent.Nodes.Add(nodeWrapper);
|
||||
|
||||
LoadPropertyObjects(prob.SubObjects, nodeWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode.Tag != null)
|
||||
ParentEditor.ObjectSelected.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,13 +28,25 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.stPropertyGrid1 = new Toolbox.Library.Forms.STPropertyGrid();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// stPropertyGrid1
|
||||
//
|
||||
this.stPropertyGrid1.AutoScroll = true;
|
||||
this.stPropertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.stPropertyGrid1.Location = new System.Drawing.Point(0, 0);
|
||||
this.stPropertyGrid1.Name = "stPropertyGrid1";
|
||||
this.stPropertyGrid1.ShowHintDisplay = true;
|
||||
this.stPropertyGrid1.Size = new System.Drawing.Size(395, 314);
|
||||
this.stPropertyGrid1.TabIndex = 0;
|
||||
//
|
||||
// MuuntPropertiesEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(395, 314);
|
||||
this.Controls.Add(this.stPropertyGrid1);
|
||||
this.Name = "MuuntPropertiesEditor";
|
||||
this.Text = "Properties Editor";
|
||||
this.ResumeLayout(false);
|
||||
@ -42,5 +54,7 @@
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Toolbox.Library.Forms.STPropertyGrid stPropertyGrid1;
|
||||
}
|
||||
}
|
@ -12,6 +12,8 @@ namespace FirstPlugin.MuuntEditor
|
||||
{
|
||||
public partial class MuuntPropertiesEditor : MuuntEditorDocker
|
||||
{
|
||||
public EventHandler ProperyChanged;
|
||||
|
||||
private MuuntEditor ParentEditor;
|
||||
|
||||
public MuuntPropertiesEditor(MuuntEditor editor)
|
||||
@ -19,5 +21,15 @@ namespace FirstPlugin.MuuntEditor
|
||||
InitializeComponent();
|
||||
ParentEditor = editor;
|
||||
}
|
||||
|
||||
public void LoadProperty(object prob)
|
||||
{
|
||||
stPropertyGrid1.LoadProperty(prob, LoadAction);
|
||||
}
|
||||
|
||||
private void LoadAction()
|
||||
{
|
||||
ProperyChanged.Invoke(null, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
using FirstPlugin.Turbo.CourseMuuntStructs;
|
||||
|
||||
namespace FirstPlugin.MuuntEditor
|
||||
{
|
||||
public class PathDoublePointDrawableContainer : PropertyObject, I2DDrawableContainer
|
||||
{
|
||||
public Color PathColor;
|
||||
|
||||
public PathDoublePointDrawableContainer(string name, Color color)
|
||||
{
|
||||
Name = name;
|
||||
PathColor = color;
|
||||
}
|
||||
|
||||
public List<BasePathGroup> PathGroups
|
||||
{
|
||||
get
|
||||
{
|
||||
var groups = new List<BasePathGroup>();
|
||||
foreach (var group in SubObjects)
|
||||
groups.Add((BasePathGroup)group);
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
|
||||
private IDrawableObject drawable;
|
||||
public IDrawableObject Drawable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (drawable == null)
|
||||
drawable = new RenderableDoublePointPath(PathGroups, PathColor);
|
||||
|
||||
return drawable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
using FirstPlugin.Turbo.CourseMuuntStructs;
|
||||
|
||||
namespace FirstPlugin.MuuntEditor
|
||||
{
|
||||
public class PathDrawableContainer : ObjectGroup, IDrawableContainer
|
||||
public class PathDrawableContainer : PropertyObject, I2DDrawableContainer
|
||||
{
|
||||
public PathDrawableContainer(string name) {
|
||||
public Color PathColor;
|
||||
|
||||
public PathDrawableContainer(string name, Color color) {
|
||||
Name = name;
|
||||
PathColor = color;
|
||||
}
|
||||
|
||||
public List<BasePathGroup> PathGroups
|
||||
@ -18,7 +21,7 @@ namespace FirstPlugin.MuuntEditor
|
||||
get
|
||||
{
|
||||
var groups = new List<BasePathGroup>();
|
||||
foreach (var group in Objects)
|
||||
foreach (var group in SubObjects)
|
||||
groups.Add((BasePathGroup)group);
|
||||
return groups;
|
||||
}
|
||||
@ -30,7 +33,7 @@ namespace FirstPlugin.MuuntEditor
|
||||
get
|
||||
{
|
||||
if (drawable == null)
|
||||
drawable = new RenderablePath(PathGroups);
|
||||
drawable = new RenderablePath(PathGroups, PathColor);
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
using FirstPlugin.Turbo.CourseMuuntStructs;
|
||||
using FirstPlugin.Turbo;
|
||||
@ -28,23 +28,43 @@ namespace FirstPlugin.MuuntEditor
|
||||
Prop = (Dictionary<string, dynamic>)byml,
|
||||
}));
|
||||
|
||||
PathDrawableContainer lapPaths = new PathDrawableContainer("Lap Paths");
|
||||
PathDrawableContainer enemyPaths = new PathDrawableContainer("Enemy Paths");
|
||||
Groups.Add(lapPaths);
|
||||
Groups.Add(enemyPaths);
|
||||
var pathGroup = new ObjectGroup("Scene Objects");
|
||||
Groups.Add(pathGroup);
|
||||
PathDoublePointDrawableContainer lapPaths = new PathDoublePointDrawableContainer("Lap Paths", Color.Blue);
|
||||
PathDrawableContainer enemyPaths = new PathDrawableContainer("Enemy Paths", Color.Red);
|
||||
PathDrawableContainer glidePaths = new PathDrawableContainer("Glide Paths", Color.Orange);
|
||||
PathDrawableContainer itemPaths = new PathDrawableContainer("Item Paths", Color.Green);
|
||||
PathDrawableContainer steerAssitPaths = new PathDrawableContainer("Steer Assist Paths", Color.Cyan);
|
||||
PathDrawableContainer gravityPaths = new PathDrawableContainer("Gravity Paths", Color.Purple);
|
||||
PathDrawableContainer pullPaths = new PathDrawableContainer("Pull Paths", Color.DarkSlateGray);
|
||||
PathDrawableContainer paths = new PathDrawableContainer("Paths", Color.Black);
|
||||
PathDrawableContainer objPaths = new PathDrawableContainer("Object Paths", Color.Brown);
|
||||
PathDrawableContainer jugemPaths = new PathDrawableContainer("Latiku Paths", Color.Pink);
|
||||
PathDrawableContainer introCameras = new PathDrawableContainer("Intro Camera", Color.Yellow);
|
||||
|
||||
pathGroup.Objects.Add(lapPaths);
|
||||
pathGroup.Objects.Add(enemyPaths);
|
||||
pathGroup.Objects.Add(glidePaths);
|
||||
pathGroup.Objects.Add(itemPaths);
|
||||
pathGroup.Objects.Add(steerAssitPaths);
|
||||
pathGroup.Objects.Add(gravityPaths);
|
||||
pathGroup.Objects.Add(pullPaths);
|
||||
pathGroup.Objects.Add(paths);
|
||||
pathGroup.Objects.Add(objPaths);
|
||||
pathGroup.Objects.Add(jugemPaths);
|
||||
pathGroup.Objects.Add(introCameras);
|
||||
|
||||
for (int i = 0; i < courseMuunt.LapPaths.Count; i++)
|
||||
{
|
||||
courseMuunt.LapPaths[i].Name = $"Group [{i}]";
|
||||
lapPaths.Objects.Add(courseMuunt.LapPaths[i]);
|
||||
lapPaths.SubObjects.Add(courseMuunt.LapPaths[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < courseMuunt.EnemyPaths.Count; i++)
|
||||
{
|
||||
courseMuunt.EnemyPaths[i].Name = $"Group [{i}]";
|
||||
enemyPaths.Objects.Add(courseMuunt.EnemyPaths[i]);
|
||||
enemyPaths.SubObjects.Add(courseMuunt.EnemyPaths[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,13 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using OpenTK;
|
||||
using GL_EditorFramework.EditorDrawables;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using FirstPlugin.MuuntEditor;
|
||||
using Toolbox.Library;
|
||||
|
||||
namespace FirstPlugin.Turbo.CourseMuuntStructs
|
||||
{
|
||||
public class BasePathPoint : PropertyObject, IObject, IPickable2DObject
|
||||
public class BasePathPoint : PropertyObject, IObject, IPickable2DObject, I3DDrawableContainer
|
||||
{
|
||||
public Action OnPathMoved;
|
||||
|
||||
@ -22,6 +23,20 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
|
||||
}
|
||||
}
|
||||
|
||||
public List<AbstractGlDrawable> Drawables
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<AbstractGlDrawable>() {
|
||||
new TransformableObject(Translate, Quaternion.Identity, new Vector3(1))
|
||||
};
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSelected { get; set; }
|
||||
public bool IsHovered { get; set; }
|
||||
|
||||
@ -58,7 +73,7 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
|
||||
|
||||
public void PickTranslate(float X, float Y, float Z)
|
||||
{
|
||||
Translate = new Vector3(X, Y, Z);
|
||||
Translate = new Vector3(Translate.X - X, Translate.Y - Z, Translate.Z - Y);
|
||||
}
|
||||
|
||||
public const string N_Translate = "Translate";
|
||||
|
@ -10,7 +10,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace GL_EditorFramework.EditorDrawables
|
||||
{
|
||||
public class RenderablePathPoint : EditableObject
|
||||
public class RenderablePathPoint : SingleObject
|
||||
{
|
||||
public bool CanConnect = true;
|
||||
|
||||
@ -18,7 +18,6 @@ namespace GL_EditorFramework.EditorDrawables
|
||||
|
||||
public bool IsNormalTanTransform = false;
|
||||
|
||||
protected Vector3 position = new Vector3(0, 0, 0);
|
||||
protected Vector3 scale = new Vector3(1, 1, 1);
|
||||
protected Vector3 rotate = new Vector3(0, 0, 0);
|
||||
|
||||
@ -33,10 +32,10 @@ namespace GL_EditorFramework.EditorDrawables
|
||||
|
||||
public Vector4 Color = new Vector4(0f, 0.25f, 1f, 1f);
|
||||
|
||||
public Vector3 Position;
|
||||
public Vector3 Scale;
|
||||
public Vector3 Scale = new Vector3(1,1,1);
|
||||
|
||||
public RenderablePathPoint(Vector4 color, Vector3 pos, Vector3 rot, Vector3 sca, object nodeObject)
|
||||
: base(pos)
|
||||
{
|
||||
NodeObject = nodeObject;
|
||||
|
||||
@ -45,13 +44,13 @@ namespace GL_EditorFramework.EditorDrawables
|
||||
}
|
||||
|
||||
public RenderablePathPoint(Vector3 pos, Vector3 normal, Vector3 tangent, Vector3 sca)
|
||||
: base(pos)
|
||||
{
|
||||
UpdateTransform(pos, normal, tangent, sca);
|
||||
}
|
||||
|
||||
public void UpdateTransform(Vector3 pos, Vector3 rot, Vector3 sca)
|
||||
{
|
||||
position = pos;
|
||||
rotate = rot;
|
||||
scale = new Vector3(sca / 2);
|
||||
}
|
||||
@ -113,7 +112,7 @@ namespace GL_EditorFramework.EditorDrawables
|
||||
return;
|
||||
|
||||
control.UpdateModelMatrix(Matrix4.CreateScale(0.5f) *
|
||||
Matrix4.CreateTranslation(position));
|
||||
Matrix4.CreateTranslation(Position));
|
||||
|
||||
Renderers.ColorBlockRenderer.Draw(control, pass, Color, Color, control.NextPickingColor());
|
||||
|
||||
@ -127,7 +126,7 @@ namespace GL_EditorFramework.EditorDrawables
|
||||
bool hovered = editorScene.Hovered == this;
|
||||
|
||||
control.UpdateModelMatrix(Matrix4.CreateScale(0.5f) *
|
||||
Matrix4.CreateTranslation(Selected ? editorScene.CurrentAction.NewPos(position) : position));
|
||||
Matrix4.CreateTranslation(Selected ? editorScene.CurrentAction.NewPos(Position) : Position));
|
||||
|
||||
Vector4 blockColor;
|
||||
Vector4 lineColor;
|
||||
@ -155,7 +154,7 @@ namespace GL_EditorFramework.EditorDrawables
|
||||
return;
|
||||
|
||||
control.UpdateModelMatrix(Matrix4.CreateScale(0.5f) *
|
||||
Matrix4.CreateTranslation(position));
|
||||
Matrix4.CreateTranslation(Position));
|
||||
|
||||
Renderers.ColorBlockRenderer.Draw(control, pass, Color, Color, control.NextPickingColor());
|
||||
|
||||
@ -171,12 +170,12 @@ namespace GL_EditorFramework.EditorDrawables
|
||||
|
||||
}
|
||||
|
||||
public virtual void Translate(Vector3 lastPos, Vector3 translate, int subObj)
|
||||
public override void Translate(Vector3 lastPos, Vector3 translate, int subObj)
|
||||
{
|
||||
position = lastPos + translate;
|
||||
Position = lastPos + translate;
|
||||
}
|
||||
|
||||
public virtual void UpdatePosition(int subObj)
|
||||
public override void UpdatePosition(int subObj)
|
||||
{
|
||||
}
|
||||
|
||||
@ -218,26 +217,21 @@ namespace GL_EditorFramework.EditorDrawables
|
||||
|
||||
public override LocalOrientation GetLocalOrientation(int partIndex)
|
||||
{
|
||||
return new LocalOrientation(position);
|
||||
return new LocalOrientation(Position);
|
||||
}
|
||||
|
||||
public override bool TryStartDragging(DragActionType actionType, int hoveredPart, out LocalOrientation localOrientation, out bool dragExclusively)
|
||||
{
|
||||
localOrientation = new LocalOrientation(position);
|
||||
localOrientation = new LocalOrientation(Position);
|
||||
dragExclusively = false;
|
||||
return Selected;
|
||||
}
|
||||
|
||||
public override bool IsInRange(float range, float rangeSquared, Vector3 pos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdateNodePosition()
|
||||
{
|
||||
if (NodeObject is BasePathPoint)
|
||||
{
|
||||
((BasePathPoint)NodeObject).Translate = position;
|
||||
((BasePathPoint)NodeObject).Translate = Position;
|
||||
((BasePathPoint)NodeObject).Scale = scale;
|
||||
((BasePathPoint)NodeObject).Rotate = rotate;
|
||||
|
||||
@ -248,15 +242,15 @@ namespace GL_EditorFramework.EditorDrawables
|
||||
{
|
||||
if (Color == new Vector4(1, 0, 0, 1))
|
||||
{
|
||||
((Course_MapCamera_bin)NodeObject).cameraData.PositionX = position.X;
|
||||
((Course_MapCamera_bin)NodeObject).cameraData.PositionY = position.Y;
|
||||
((Course_MapCamera_bin)NodeObject).cameraData.PositionZ = position.Z;
|
||||
((Course_MapCamera_bin)NodeObject).cameraData.PositionX = Position.X;
|
||||
((Course_MapCamera_bin)NodeObject).cameraData.PositionY = Position.Y;
|
||||
((Course_MapCamera_bin)NodeObject).cameraData.PositionZ = Position.Z;
|
||||
}
|
||||
else
|
||||
{
|
||||
((Course_MapCamera_bin)NodeObject).cameraData.TargetX = position.X;
|
||||
((Course_MapCamera_bin)NodeObject).cameraData.TargetY = position.Y;
|
||||
((Course_MapCamera_bin)NodeObject).cameraData.TargetZ = position.Z;
|
||||
((Course_MapCamera_bin)NodeObject).cameraData.TargetX = Position.X;
|
||||
((Course_MapCamera_bin)NodeObject).cameraData.TargetY = Position.Y;
|
||||
((Course_MapCamera_bin)NodeObject).cameraData.TargetZ = Position.Z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,14 +21,16 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
|
||||
if (bymlNode is Dictionary<string, dynamic>) Prop = (Dictionary<string, dynamic>)bymlNode;
|
||||
else throw new Exception("Not a dictionary");
|
||||
|
||||
int index = 0;
|
||||
foreach (var point in this["PathPt"])
|
||||
{
|
||||
PathPoints.Add(new LapPathPoint(point));
|
||||
PathPoints.Add(new LapPathPoint(point) { Name = $"Point [{index++}]" });
|
||||
}
|
||||
|
||||
index = 0;
|
||||
foreach (var point in this["ReturnPoints"])
|
||||
{
|
||||
ReturnPoints.Add(new ReturnPoint(point));
|
||||
ReturnPoints.Add(new ReturnPoint(point) { Name = $"Point [{index++}]" });
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +43,7 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
|
||||
set { this[N_LapPathGroup] = value; }
|
||||
}
|
||||
|
||||
public int ReturnPointsError
|
||||
public bool ReturnPointsError
|
||||
{
|
||||
get { return this[N_ReturnPointsError]; }
|
||||
set { this[N_ReturnPointsError] = value; }
|
||||
|
@ -0,0 +1,172 @@
|
||||
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
|
||||
/// This one in particular includes 2 left and right points that connect together
|
||||
/// </summary>
|
||||
public class RenderableDoublePointPath : IDrawableObject
|
||||
{
|
||||
public Color LineColor = Color.Green;
|
||||
|
||||
public List<BasePathGroup> PathGroups = new List<BasePathGroup>();
|
||||
|
||||
public RenderableDoublePointPath(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);
|
||||
|
||||
//Draw a line repesenting the size of the path area
|
||||
var point1 = RotatePoint(translate, path.Scale.X / 2, path.Scale.Z / 2, path.Scale.Y / 2, path.Rotate);
|
||||
var point2 = RotatePoint(translate, -(path.Scale.X / 2), -(path.Scale.Z / 2), -(path.Scale.Y / 2), path.Rotate);
|
||||
//
|
||||
GL.PushMatrix();
|
||||
GL.Translate(translate);
|
||||
GL.Rotate(MathHelper.RadiansToDegrees(path.Rotate.X), 1, 0, 0);
|
||||
GL.Rotate(MathHelper.RadiansToDegrees(path.Rotate.Z), 0, 1, 0);
|
||||
GL.Rotate(MathHelper.RadiansToDegrees(path.Rotate.Y), 0, 0, 1);
|
||||
|
||||
GL.Color3(LineColor);
|
||||
GL.Begin(PrimitiveType.Lines);
|
||||
GL.Vertex3(point1);
|
||||
GL.Vertex3(point2);
|
||||
GL.End();
|
||||
|
||||
GL.PopMatrix();
|
||||
|
||||
//Draw 2 points repesenting the edges of the path
|
||||
|
||||
|
||||
/* if (path.IsSelected)
|
||||
Render2D.DrawFilledCircle(translate, Color.LightGreen, 5, 40, true);
|
||||
else if (path.IsHovered)
|
||||
Render2D.DrawFilledCircle(translate, LineColor.Lighten(40), 6, 40, true);
|
||||
else
|
||||
Render2D.DrawFilledCircle(translate, LineColor.Darken(20), 5, 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);
|
||||
}
|
||||
|
||||
private void DrawPathPoint(Vector3 center, Vector3 scale, Vector3 rotate, Color color, bool useWireFrame = false)
|
||||
{
|
||||
GL.Color3(color);
|
||||
|
||||
float sizeX = scale.X;
|
||||
float sizeY = scale.Y;
|
||||
float sizeZ = scale.Z;
|
||||
|
||||
|
||||
PrimitiveType primitiveType = PrimitiveType.Quads;
|
||||
if (useWireFrame)
|
||||
{
|
||||
GL.LineWidth(2);
|
||||
primitiveType = PrimitiveType.LineLoop;
|
||||
}
|
||||
|
||||
GL.Begin(primitiveType);
|
||||
GL.Normal3(0.0f, 1.0f, 0.0f);
|
||||
GL.Vertex3(center.X + sizeX, center.Y + sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y + sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y + sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y + sizeY, center.Z + sizeZ);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(primitiveType);
|
||||
GL.Normal3(0.0f, 0.0f, 1.0f);
|
||||
GL.Vertex3(center.X + sizeX, center.Y - sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y - sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y - sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y - sizeY, center.Z - sizeZ);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(primitiveType);
|
||||
GL.Normal3(1.0f, 0.0f, 0.0f);
|
||||
GL.Vertex3(center.X + sizeX, center.Y + sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y + sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y - sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y - sizeY, center.Z + sizeZ);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(primitiveType);
|
||||
GL.Normal3(-1.0f, 0.0f, 0.0f);
|
||||
GL.Vertex3(center.X + sizeX, center.Y - sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y - sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y + sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y + sizeY, center.Z - sizeZ);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(primitiveType);
|
||||
GL.Normal3(0.0f, -1.0f, 0.0f);
|
||||
GL.Vertex3(center.X - sizeX, center.Y + sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y + sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y - sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X - sizeX, center.Y - sizeY, center.Z + sizeZ);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(primitiveType);
|
||||
GL.Normal3(0.0f, 0.0f, -1.0f);
|
||||
GL.Vertex3(center.X + sizeX, center.Y + sizeY, center.Z - sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y + sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y - sizeY, center.Z + sizeZ);
|
||||
GL.Vertex3(center.X + sizeX, center.Y - sizeY, center.Z - sizeZ);
|
||||
GL.End();
|
||||
}
|
||||
|
||||
private Vector3 RotatePoint(Vector3 translate, float X, float Y, float Z, Vector3 rotate)
|
||||
{
|
||||
return new Vector3(X, Y, Z);
|
||||
|
||||
Matrix4 rotationZ = Matrix4.CreateRotationZ(rotate.Y);
|
||||
Matrix4 rotationY = Matrix4.CreateRotationY(rotate.Z);
|
||||
Matrix4 rotationX = Matrix4.CreateRotationX(rotate.X);
|
||||
|
||||
Matrix4 transMat = Matrix4.CreateTranslation(translate);
|
||||
Matrix4 comb = (rotationX * rotationY * rotationZ) * transMat;
|
||||
Vector3 pos = new Vector3(X, Y, Z);
|
||||
return Vector3.TransformPosition(pos, comb);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using FirstPlugin.Turbo.CourseMuuntStructs;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.IO;
|
||||
|
||||
namespace FirstPlugin.MuuntEditor
|
||||
{
|
||||
@ -19,13 +20,15 @@ namespace FirstPlugin.MuuntEditor
|
||||
|
||||
public List<BasePathGroup> PathGroups = new List<BasePathGroup>();
|
||||
|
||||
public RenderablePath(List<BasePathGroup> pathGroups)
|
||||
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)
|
||||
@ -33,11 +36,11 @@ namespace FirstPlugin.MuuntEditor
|
||||
var translate = new Vector3(path.Translate.X, path.Translate.Z, path.Translate.Y);
|
||||
|
||||
if (path.IsSelected)
|
||||
Render2D.DrawFilledCircle(new Vector2(translate.X, translate.Y), Color.Green, 30, 40, true);
|
||||
Render2D.DrawFilledCircle(translate, Color.LightGreen, 30, 40, true);
|
||||
else if (path.IsHovered)
|
||||
Render2D.DrawFilledCircle(new Vector2(translate.X, translate.Y), Color.Yellow, 40, 40, true);
|
||||
Render2D.DrawFilledCircle(translate, LineColor.Lighten(40), 40, 40, true);
|
||||
else
|
||||
Render2D.DrawFilledCircle(new Vector2(translate.X, translate.Y), Color.Red, 30, 40, true);
|
||||
Render2D.DrawFilledCircle(translate, LineColor.Darken(20), 30, 40, true);
|
||||
|
||||
GL.LineWidth(2f);
|
||||
foreach (var nextPt in path.NextPoints)
|
||||
@ -62,6 +65,7 @@ namespace FirstPlugin.MuuntEditor
|
||||
}
|
||||
}
|
||||
}
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GL_EditorFramework.EditorDrawables;
|
||||
using GL_EditorFramework.GL_Core;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using GL_EditorFramework;
|
||||
using OpenTK;
|
||||
using WinInput = System.Windows.Input;
|
||||
using static GL_EditorFramework.EditorDrawables.EditorSceneBase;
|
||||
|
||||
namespace FirstPlugin.MuuntEditor
|
||||
{
|
||||
class TransformableObject : SingleObject
|
||||
{
|
||||
public TransformableObject(Vector3 pos, Quaternion rot, Vector3 scale)
|
||||
: base(pos)
|
||||
{
|
||||
rotation = rot;
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public override string ToString() => "block";
|
||||
|
||||
public Quaternion rotation = Quaternion.Identity;
|
||||
|
||||
public Vector3 scale = new Vector3(1, 1, 1);
|
||||
|
||||
public override void Draw(GL_ControlModern control, Pass pass, EditorSceneBase editorScene)
|
||||
{
|
||||
if (pass == Pass.TRANSPARENT)
|
||||
return;
|
||||
|
||||
bool hovered = editorScene.Hovered == this;
|
||||
|
||||
control.UpdateModelMatrix(
|
||||
Matrix4.CreateScale((Selected ? editorScene.CurrentAction.NewScale(scale) : scale) * 0.5f) *
|
||||
Matrix4.CreateFromQuaternion(Selected ? editorScene.CurrentAction.NewRot(rotation) : rotation) *
|
||||
Matrix4.CreateTranslation(Selected ? editorScene.CurrentAction.NewPos(Position) : Position));
|
||||
|
||||
Vector4 blockColor;
|
||||
Vector4 lineColor;
|
||||
|
||||
if (hovered && Selected)
|
||||
lineColor = hoverColor;
|
||||
else if (hovered || Selected)
|
||||
lineColor = selectColor;
|
||||
else
|
||||
lineColor = Color;
|
||||
|
||||
if (hovered && Selected)
|
||||
blockColor = Color * 0.5f + hoverColor * 0.5f;
|
||||
else if (hovered || Selected)
|
||||
blockColor = Color * 0.5f + selectColor * 0.5f;
|
||||
else
|
||||
blockColor = Color;
|
||||
|
||||
Renderers.ColorBlockRenderer.Draw(control, pass, blockColor, lineColor, control.NextPickingColor());
|
||||
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlLegacy control, Pass pass, EditorSceneBase editorScene)
|
||||
{
|
||||
if (pass == Pass.TRANSPARENT)
|
||||
return;
|
||||
|
||||
bool hovered = editorScene.Hovered == this;
|
||||
|
||||
control.UpdateModelMatrix(
|
||||
Matrix4.CreateScale((Selected ? editorScene.CurrentAction.NewScale(scale) : scale) * 0.5f) *
|
||||
Matrix4.CreateFromQuaternion(Selected ? editorScene.CurrentAction.NewRot(rotation) : rotation) *
|
||||
Matrix4.CreateTranslation(Selected ? editorScene.CurrentAction.NewPos(Position) : Position));
|
||||
|
||||
Vector4 blockColor;
|
||||
Vector4 lineColor;
|
||||
|
||||
if (hovered && Selected)
|
||||
lineColor = hoverColor;
|
||||
else if (hovered || Selected)
|
||||
lineColor = selectColor;
|
||||
else
|
||||
lineColor = Color;
|
||||
|
||||
if (hovered && Selected)
|
||||
blockColor = Color * 0.5f + hoverColor * 0.5f;
|
||||
else if (hovered || Selected)
|
||||
blockColor = Color * 0.5f + selectColor * 0.5f;
|
||||
else
|
||||
blockColor = Color;
|
||||
|
||||
Renderers.ColorBlockRenderer.Draw(control, pass, blockColor, lineColor, control.NextPickingColor());
|
||||
}
|
||||
|
||||
public override LocalOrientation GetLocalOrientation(int partIndex)
|
||||
{
|
||||
return new LocalOrientation(Position, rotation);
|
||||
}
|
||||
|
||||
public override bool TryStartDragging(DragActionType actionType, int hoveredPart, out LocalOrientation localOrientation, out bool dragExclusively)
|
||||
{
|
||||
localOrientation = new LocalOrientation(Position, rotation);
|
||||
dragExclusively = false;
|
||||
return Selected;
|
||||
}
|
||||
|
||||
public override void SetTransform(Vector3? pos, Quaternion? rot, Vector3? scale, int part, out Vector3? prevPos, out Quaternion? prevRot, out Vector3? prevScale)
|
||||
{
|
||||
prevPos = null;
|
||||
prevRot = null;
|
||||
prevScale = null;
|
||||
|
||||
if (pos.HasValue)
|
||||
{
|
||||
prevPos = Position;
|
||||
Position = pos.Value;
|
||||
}
|
||||
|
||||
if (rot.HasValue)
|
||||
{
|
||||
prevRot = rotation;
|
||||
rotation = rot.Value;
|
||||
}
|
||||
|
||||
if (scale.HasValue)
|
||||
{
|
||||
prevScale = this.scale;
|
||||
this.scale = scale.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyTransformActionToSelection(AbstractTransformAction transformAction, ref TransformChangeInfos infos)
|
||||
{
|
||||
Position = transformAction.NewPos(Position, out Vector3? prevPos);
|
||||
rotation = transformAction.NewRot(rotation, out Quaternion? prevRot);
|
||||
scale = transformAction.NewScale(scale, out Vector3? prevScale);
|
||||
infos.Add(this, 0, prevPos, prevRot, prevScale);
|
||||
}
|
||||
}
|
||||
}
|
@ -28,14 +28,11 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.stPropertyGrid1 = new Toolbox.Library.Forms.STPropertyGrid();
|
||||
this.leBtnRadio = new System.Windows.Forms.RadioButton();
|
||||
this.beBtnRadio = new System.Windows.Forms.RadioButton();
|
||||
this.mapCameraViewer1 = new MapCameraViewer();
|
||||
this.stContextMenuStrip1 = new Toolbox.Library.Forms.STContextMenuStrip(this.components);
|
||||
this.loadKCLFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.stContextMenuStrip1.SuspendLayout();
|
||||
this.mapCameraViewer1 = new Turbo.MapCameraViewer();
|
||||
this.btnCollisionPreview = new Toolbox.Library.Forms.STButton();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// stPropertyGrid1
|
||||
@ -84,24 +81,22 @@
|
||||
this.mapCameraViewer1.UseOrtho = true;
|
||||
this.mapCameraViewer1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.mapCameraViewer1_MouseDown);
|
||||
//
|
||||
// stContextMenuStrip1
|
||||
// btnCollisionPreview
|
||||
//
|
||||
this.stContextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.loadKCLFileToolStripMenuItem});
|
||||
this.stContextMenuStrip1.Name = "stContextMenuStrip1";
|
||||
this.stContextMenuStrip1.Size = new System.Drawing.Size(145, 26);
|
||||
//
|
||||
// loadKCLFileToolStripMenuItem
|
||||
//
|
||||
this.loadKCLFileToolStripMenuItem.Name = "loadKCLFileToolStripMenuItem";
|
||||
this.loadKCLFileToolStripMenuItem.Size = new System.Drawing.Size(144, 22);
|
||||
this.loadKCLFileToolStripMenuItem.Text = "Load KCL File";
|
||||
this.loadKCLFileToolStripMenuItem.Click += new System.EventHandler(this.loadKCLFileToolStripMenuItem_Click);
|
||||
this.btnCollisionPreview.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnCollisionPreview.Location = new System.Drawing.Point(174, 0);
|
||||
this.btnCollisionPreview.Name = "btnCollisionPreview";
|
||||
this.btnCollisionPreview.Size = new System.Drawing.Size(149, 23);
|
||||
this.btnCollisionPreview.TabIndex = 16;
|
||||
this.btnCollisionPreview.Text = "Open KCL (Mesh Preview)";
|
||||
this.btnCollisionPreview.UseVisualStyleBackColor = false;
|
||||
this.btnCollisionPreview.Click += new System.EventHandler(this.btnCollisionPreview_Click);
|
||||
//
|
||||
// MK8MapCameraEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.btnCollisionPreview);
|
||||
this.Controls.Add(this.mapCameraViewer1);
|
||||
this.Controls.Add(this.beBtnRadio);
|
||||
this.Controls.Add(this.leBtnRadio);
|
||||
@ -109,7 +104,6 @@
|
||||
this.Name = "MK8MapCameraEditor";
|
||||
this.Size = new System.Drawing.Size(720, 437);
|
||||
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MK8MapCameraEditor_MouseDown);
|
||||
this.stContextMenuStrip1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -121,7 +115,6 @@
|
||||
private System.Windows.Forms.RadioButton beBtnRadio;
|
||||
private System.Windows.Forms.RadioButton leBtnRadio;
|
||||
private MapCameraViewer mapCameraViewer1;
|
||||
private Toolbox.Library.Forms.STContextMenuStrip stContextMenuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem loadKCLFileToolStripMenuItem;
|
||||
private Toolbox.Library.Forms.STButton btnCollisionPreview;
|
||||
}
|
||||
}
|
||||
|
@ -9,13 +9,17 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Toolbox.Library.Forms;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.IO;
|
||||
using ByamlExt.Byaml;
|
||||
using ByamlExt;
|
||||
using FirstPlugin.MuuntEditor;
|
||||
|
||||
namespace FirstPlugin.Turbo
|
||||
{
|
||||
public partial class MK8MapCameraEditor : UserControl, IFIleEditor
|
||||
{
|
||||
public List<MuuntCollisionObject> CollisionObjects = new List<MuuntCollisionObject>();
|
||||
|
||||
public List<IFileFormat> GetFileFormats()
|
||||
{
|
||||
return new List<IFileFormat>() { activeCameraFile };
|
||||
@ -40,7 +44,7 @@ namespace FirstPlugin.Turbo
|
||||
|
||||
stPropertyGrid1.LoadProperty(activeCameraFile.cameraData, OnPropertyChanged);
|
||||
|
||||
mapCameraViewer1.LoadCameraFile(mapCamera);
|
||||
mapCameraViewer1.LoadCameraFile(mapCamera, this);
|
||||
}
|
||||
|
||||
public void OnPropertyChanged() { }
|
||||
@ -60,27 +64,31 @@ namespace FirstPlugin.Turbo
|
||||
|
||||
}
|
||||
|
||||
private void loadKCLFileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void MK8MapCameraEditor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCollisionPreview_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = Utils.GetAllFilters(typeof(KCL));
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var fileFormat = Toolbox.Library.IO.STFileLoader.OpenFileFormat(ofd.FileName);
|
||||
var fileFormat = STFileLoader.OpenFileFormat(ofd.FileName);
|
||||
if (fileFormat != null && fileFormat is KCL)
|
||||
{
|
||||
var kcl = fileFormat as KCL;
|
||||
mapCameraViewer1.LoadCollision(kcl);
|
||||
}
|
||||
LoadCollision((KCL)fileFormat);
|
||||
}
|
||||
}
|
||||
|
||||
private void MK8MapCameraEditor_MouseDown(object sender, MouseEventArgs e)
|
||||
private void LoadCollision(KCL kcl)
|
||||
{
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
stContextMenuStrip1.Show(Cursor.Position);
|
||||
}
|
||||
MuuntCollisionObject col = new MuuntCollisionObject();
|
||||
col.CollisionFile = kcl;
|
||||
col.Renderer = new KCLRendering2D(kcl);
|
||||
CollisionObjects.Add(col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,4 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="stContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Toolbox.Library.Forms;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using Toolbox.Library.IO;
|
||||
using Toolbox.Library;
|
||||
using System.Drawing;
|
||||
using FirstPlugin.Turbo;
|
||||
@ -12,44 +13,177 @@ using OpenTK;
|
||||
|
||||
namespace FirstPlugin.Turbo
|
||||
{
|
||||
public class MapCameraViewer : Viewport2D
|
||||
public class CameraPoint : IPickable2DObject
|
||||
{
|
||||
private KCL CollisionFile;
|
||||
private KCLRendering2D KCLRender;
|
||||
private Course_MapCamera_bin MapCamera;
|
||||
public bool IsTarget = false;
|
||||
|
||||
public void LoadCollision(KCL kcl) {
|
||||
CollisionFile = kcl;
|
||||
KCLRender = new KCLRendering2D(kcl);
|
||||
public bool IsSelected { get; set; }
|
||||
public bool IsHovered { get; set; }
|
||||
|
||||
public Vector3 Translate
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector3 translate = new Vector3();
|
||||
if (IsTarget)
|
||||
translate = new Vector3(cameraData.TargetX,
|
||||
cameraData.TargetY, cameraData.TargetZ);
|
||||
else
|
||||
translate = new Vector3(cameraData.PositionX,
|
||||
cameraData.PositionY, cameraData.PositionZ);
|
||||
return translate;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (IsTarget)
|
||||
{
|
||||
cameraData.TargetX = value.X;
|
||||
cameraData.TargetY = value.Y;
|
||||
cameraData.TargetZ = value.Z;
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraData.PositionX = value.X;
|
||||
cameraData.PositionY = value.Y;
|
||||
cameraData.PositionZ = value.Z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadCameraFile(Course_MapCamera_bin camera) {
|
||||
public bool IsHit(float X, float Y)
|
||||
{
|
||||
return new STRectangle(Translate.X, Translate.Z, 500, 500).IsHit((int)X, (int)Y);
|
||||
}
|
||||
|
||||
public void PickTranslate(float X, float Y, float Z)
|
||||
{
|
||||
Translate -= new Vector3(X,Z,Y);
|
||||
}
|
||||
|
||||
Course_MapCamera_bin.CameraData cameraData;
|
||||
|
||||
public CameraPoint(Course_MapCamera_bin.CameraData data, bool isTarget)
|
||||
{
|
||||
cameraData = data;
|
||||
IsTarget = isTarget;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
GL.Disable(EnableCap.DepthTest);
|
||||
|
||||
Color color = Color.Red;
|
||||
if (IsTarget)
|
||||
color = Color.Green;
|
||||
if (IsHovered)
|
||||
color = Color.Yellow;
|
||||
if (IsSelected)
|
||||
color = Color.Blue;
|
||||
|
||||
Render2D.DrawFilledCircle(new Vector3(Translate.X, Translate.Z, Translate.Y), color, 300, 40, true);
|
||||
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
}
|
||||
}
|
||||
|
||||
public class MapCameraViewer : Viewport2D
|
||||
{
|
||||
public override float PreviewScale => 0.1f;
|
||||
|
||||
public byte CameraMapTransparency = 140;
|
||||
|
||||
private MK8MapCameraEditor ParentEditor;
|
||||
private Course_MapCamera_bin MapCamera;
|
||||
|
||||
private List<CameraPoint> CameraPoints = new List<CameraPoint>();
|
||||
|
||||
private STGenericTexture MapCameraTexture;
|
||||
|
||||
public void LoadCameraFile(Course_MapCamera_bin camera, MK8MapCameraEditor editor) {
|
||||
MapCamera = camera;
|
||||
ParentEditor = editor;
|
||||
|
||||
CameraPoints.Add(new CameraPoint(camera.cameraData, true));
|
||||
CameraPoints.Add(new CameraPoint(camera.cameraData, false));
|
||||
|
||||
//Try to load the mini map
|
||||
var folder = System.IO.Path.GetDirectoryName(camera.FilePath);
|
||||
if (System.IO.File.Exists($"{folder}/course_maptexture.bflim"))
|
||||
{
|
||||
var fileFormat = STFileLoader.OpenFileFormat($"{folder}/course_maptexture.bflim");
|
||||
if (fileFormat is BFLIM)
|
||||
MapCameraTexture = fileFormat as BFLIM;
|
||||
}
|
||||
if (System.IO.File.Exists($"{folder}/course_maptexture.bntx"))
|
||||
{
|
||||
var fileFormat = STFileLoader.OpenFileFormat($"{folder}/course_maptexture.bntx");
|
||||
if (fileFormat is BNTX)
|
||||
MapCameraTexture = ((BNTX)fileFormat).Textures.Values.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public override List<IPickable2DObject> GetPickableObjects()
|
||||
{
|
||||
var picks = new List<IPickable2DObject>();
|
||||
foreach (var point in CameraPoints)
|
||||
picks.Add(point);
|
||||
|
||||
return picks;
|
||||
}
|
||||
|
||||
private float GetAngle()
|
||||
{
|
||||
var data = MapCamera.cameraData;
|
||||
|
||||
float xDiff = data.PositionX - data.TargetX;
|
||||
float yDiff = data.PositionZ - data.TargetZ;
|
||||
return (float)(Math.Atan2(yDiff, xDiff) * 180.0 / Math.PI);
|
||||
}
|
||||
|
||||
public override void RenderSceme()
|
||||
{
|
||||
if (MapCamera == null) return;
|
||||
|
||||
GL.PushMatrix();
|
||||
|
||||
GL.Scale(0.1f, 0.1f ,1.0f);
|
||||
GL.DepthFunc(DepthFunction.Lequal);
|
||||
|
||||
var cam = MapCamera.cameraData;
|
||||
|
||||
if (CollisionFile != null)
|
||||
DrawCollision(CollisionFile);
|
||||
foreach (var kcl in ParentEditor.CollisionObjects)
|
||||
kcl.Renderer.Draw(Camera.ModelViewMatrix);
|
||||
|
||||
Render2D.DrawRectangle(cam.BoundingWidth, cam.BoundingHeight, Color.White, true);
|
||||
//Draw mini map and bind texture
|
||||
|
||||
Render2D.DrawCircle(new Vector2(cam.PositionX, cam.PositionY), Color.Red);
|
||||
Render2D.DrawCircle(new Vector2(cam.TargetX, cam.TargetY), Color.Green);
|
||||
var angle = GetAngle();
|
||||
var scaleX = cam.PositionX - cam.TargetX;
|
||||
var scaleY = cam.PositionZ - cam.TargetZ;
|
||||
|
||||
GL.PushMatrix();
|
||||
GL.Rotate(angle + -90, Vector3.UnitZ);
|
||||
GL.Enable(EnableCap.Texture2D);
|
||||
GL.DepthFunc(DepthFunction.Always);
|
||||
|
||||
if (MapCameraTexture != null)
|
||||
{
|
||||
if (MapCameraTexture.RenderableTex == null || !MapCameraTexture.RenderableTex.GLInitialized)
|
||||
MapCameraTexture.LoadOpenGLTexture();
|
||||
MapCameraTexture.RenderableTex?.Bind();
|
||||
}
|
||||
|
||||
Render2D.DrawRectangle(cam.BoundingWidth, cam.BoundingHeight,
|
||||
Color.FromArgb(CameraMapTransparency, Color.White), false);
|
||||
|
||||
GL.PopMatrix();
|
||||
}
|
||||
GL.DepthFunc(DepthFunction.Lequal);
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
GL.Disable(EnableCap.Texture2D);
|
||||
GL.Disable(EnableCap.DepthTest);
|
||||
|
||||
private void DrawCollision(KCL kcl) {
|
||||
KCLRender.Draw(Camera.ModelViewMatrix);
|
||||
Render2D.DrawRectangle(cam.BoundingWidth, cam.BoundingHeight, Color.Red, true);
|
||||
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
|
||||
foreach (var obj in CameraPoints)
|
||||
obj.Draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ namespace Toolbox.Library
|
||||
GlobalTransform = Matrix4.Identity;
|
||||
|
||||
COLLADA collada = COLLADA.Load(FileName);
|
||||
|
||||
|
||||
|
||||
//Check axis up
|
||||
if (collada.asset != null)
|
||||
{
|
||||
|
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Toolbox.Library.Forms
|
||||
{
|
||||
public class TreeviewDragSorter : TreeView
|
||||
{
|
||||
public EventHandler OnTreeNodeSorted;
|
||||
|
||||
protected override void OnDragDrop(DragEventArgs drgevent)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -281,7 +281,6 @@ namespace Toolbox.Library
|
||||
GL_ControlModern.MainDrawable = scene;
|
||||
if (GL_ControlLegacy != null)
|
||||
GL_ControlLegacy.MainDrawable = scene;
|
||||
|
||||
}
|
||||
|
||||
public void UpdateViewport()
|
||||
|
@ -928,7 +928,6 @@ namespace Toolbox.Library
|
||||
|
||||
progressBar.Value = 100;
|
||||
progressBar.Close();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
32
Switch_Toolbox_Library/OpenGL/OpenGL2DEnums.cs
Normal file
32
Switch_Toolbox_Library/OpenGL/OpenGL2DEnums.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Toolbox.Library.OpenGL2D
|
||||
{
|
||||
public enum PickAction
|
||||
{
|
||||
None,
|
||||
DragTopRight,
|
||||
DragTopLeft,
|
||||
DragTop,
|
||||
DragLeft,
|
||||
DragRight,
|
||||
DragBottom,
|
||||
DragBottomLeft,
|
||||
DragBottomRight,
|
||||
Translate,
|
||||
Scale,
|
||||
Rotate
|
||||
}
|
||||
|
||||
public enum PickAxis
|
||||
{
|
||||
All,
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ namespace Toolbox.Library
|
||||
{
|
||||
public class OpenGLHelper
|
||||
{
|
||||
public static Point convertScreenToWorldCoords(int x, int y, bool isTopDown = false)
|
||||
public static Point convertScreenToWorldCoords(int x, int y)
|
||||
{
|
||||
int[] viewport = new int[4];
|
||||
Matrix4 modelViewMatrix, projectionMatrix;
|
||||
@ -21,13 +21,13 @@ namespace Toolbox.Library
|
||||
Vector2 mouse;
|
||||
mouse.X = x;
|
||||
mouse.Y = y;
|
||||
Vector4 vector = UnProject(ref projectionMatrix, modelViewMatrix, new Size(viewport[2], viewport[3]), mouse, isTopDown);
|
||||
Vector4 vector = UnProject(ref projectionMatrix, modelViewMatrix, new Size(viewport[2], viewport[3]), mouse);
|
||||
Point coords = new Point((int)vector.X, (int)vector.Y);
|
||||
|
||||
return coords;
|
||||
}
|
||||
|
||||
public static Vector4 UnProject(ref Matrix4 projection, Matrix4 view, Size viewport, Vector2 mouse, bool isTopDown)
|
||||
public static Vector4 UnProject(ref Matrix4 projection, Matrix4 view, Size viewport, Vector2 mouse)
|
||||
{
|
||||
Vector4 vec;
|
||||
|
||||
@ -36,12 +36,6 @@ namespace Toolbox.Library
|
||||
vec.Z = 0;
|
||||
vec.W = 1.0f;
|
||||
|
||||
if (isTopDown)
|
||||
{
|
||||
vec.Y = 0;
|
||||
vec.Z = -(2.0f * mouse.Y / (float)viewport.Height - 1);
|
||||
}
|
||||
|
||||
Matrix4 viewInv = Matrix4.Invert(view);
|
||||
Matrix4 projInv = Matrix4.Invert(projection);
|
||||
|
||||
|
@ -27,10 +27,10 @@ namespace Toolbox.Library
|
||||
GL.PopMatrix();
|
||||
}
|
||||
|
||||
public static void DrawFilledCircle(Vector2 Position, Color color, float radius = 300, byte transparency = 255, bool outline = false)
|
||||
public static void DrawFilledCircle(Vector3 Position, Color color, float radius = 300, byte transparency = 255, bool outline = false)
|
||||
{
|
||||
GL.PushMatrix();
|
||||
GL.Translate(Position.X, Position.Y, 0);
|
||||
GL.Translate(Position.X, Position.Y, Position.Z);
|
||||
GL.Scale(radius, radius, 1);
|
||||
|
||||
GL.Color4(color.R, color.G, color.B, transparency);
|
||||
@ -50,10 +50,10 @@ namespace Toolbox.Library
|
||||
DrawCircle(Position, color.Darken(20), radius);
|
||||
}
|
||||
|
||||
public static void DrawCircle(Vector2 Position, Color color, float radius = 300)
|
||||
public static void DrawCircle(Vector3 Position, Color color, float radius = 300)
|
||||
{
|
||||
GL.PushMatrix();
|
||||
GL.Translate(Position.X, Position.Y, 0);
|
||||
GL.Translate(Position.X, Position.Y, Position.Z);
|
||||
GL.Scale(radius, radius, 1);
|
||||
|
||||
GL.Color4(color);
|
||||
|
@ -10,11 +10,14 @@ using System.Windows.Forms;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.OpenGL2D;
|
||||
|
||||
namespace Toolbox.Library.Forms
|
||||
{
|
||||
public class Viewport2D : UserControl
|
||||
{
|
||||
public virtual float PreviewScale => 1f;
|
||||
|
||||
public virtual bool UseOrtho { get; set; } = true;
|
||||
public virtual bool UseGrid { get; set; } = true;
|
||||
|
||||
@ -23,13 +26,13 @@ namespace Toolbox.Library.Forms
|
||||
public class Camera2D
|
||||
{
|
||||
public Matrix4 ViewMatrix = Matrix4.Identity;
|
||||
public Matrix4 ModelMatrix = Matrix4.Identity;
|
||||
public Matrix4 ProjectionMatrix = Matrix4.Identity;
|
||||
|
||||
public Matrix4 ModelViewMatrix
|
||||
{
|
||||
get
|
||||
{
|
||||
return ModelMatrix * ViewMatrix;
|
||||
return ViewMatrix * ProjectionMatrix;
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +45,9 @@ namespace Toolbox.Library.Forms
|
||||
|
||||
private List<IPickable2DObject> SelectedObjects = new List<IPickable2DObject>();
|
||||
|
||||
private PickAction pickAction = PickAction.None;
|
||||
private PickAxis pickAxis = PickAxis.All;
|
||||
|
||||
public Viewport2D()
|
||||
{
|
||||
glControl1 = new GLControl();
|
||||
@ -83,16 +89,25 @@ namespace Toolbox.Library.Forms
|
||||
var orthoMatrix = Matrix4.CreateOrthographic(halfW, halfH, -10000, 10000);
|
||||
GL.LoadMatrix(ref orthoMatrix);
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
Camera.ViewMatrix = orthoMatrix;
|
||||
Camera.ProjectionMatrix = orthoMatrix;
|
||||
|
||||
Matrix4 scaleMat = Matrix4.CreateScale(Camera.Zoom * PreviewScale, Camera.Zoom * PreviewScale, 1);
|
||||
Matrix4 transMat = Matrix4.CreateTranslation(Camera.Position.X, Camera.Position.Y, 0);
|
||||
|
||||
Camera.ViewMatrix = scaleMat * transMat;
|
||||
}
|
||||
else
|
||||
{
|
||||
var cameraPosition = new Vector3(Camera.Position.X, Camera.Position.Y, -(Camera.Zoom * 500));
|
||||
|
||||
var perspectiveMatrix = Matrix4.CreateRotationY(90) * Matrix4.CreateTranslation(cameraPosition) * Matrix4.CreatePerspectiveFieldOfView(1.3f, glControl1.Width / glControl1.Height, 0.01f, 100000);
|
||||
var perspectiveMatrix = Matrix4.CreatePerspectiveFieldOfView(1.3f, glControl1.Width / glControl1.Height, 0.01f, 100000);
|
||||
GL.LoadMatrix(ref perspectiveMatrix);
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
Camera.ViewMatrix = perspectiveMatrix;
|
||||
|
||||
Camera.ViewMatrix = Matrix4.CreateTranslation(cameraPosition);
|
||||
Camera.ProjectionMatrix = perspectiveMatrix;
|
||||
|
||||
GL.LoadMatrix(ref Camera.ViewMatrix);
|
||||
}
|
||||
|
||||
GL.ClearColor(BackgroundColor);
|
||||
@ -101,13 +116,8 @@ namespace Toolbox.Library.Forms
|
||||
if (UseOrtho)
|
||||
{
|
||||
GL.PushMatrix();
|
||||
GL.Scale(Camera.Zoom, Camera.Zoom, 1);
|
||||
GL.Scale(Camera.Zoom * PreviewScale, Camera.Zoom * PreviewScale, 1);
|
||||
GL.Translate(Camera.Position.X, Camera.Position.Y, 0);
|
||||
|
||||
Matrix4 scaleMat = Matrix4.CreateScale(Camera.Zoom, Camera.Zoom, 1);
|
||||
Matrix4 transMat = Matrix4.CreateTranslation(Camera.Position.X, -Camera.Position.Y, 0);
|
||||
|
||||
Camera.ModelMatrix = scaleMat * transMat;
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,6 +155,7 @@ namespace Toolbox.Library.Forms
|
||||
|
||||
if (showSelectionBox)
|
||||
{
|
||||
GL.Disable(EnableCap.DepthTest);
|
||||
GL.Begin(PrimitiveType.LineLoop);
|
||||
GL.Color4(Color.Red);
|
||||
GL.Vertex2(SelectionBox.LeftPoint, SelectionBox.BottomPoint);
|
||||
@ -152,6 +163,7 @@ namespace Toolbox.Library.Forms
|
||||
GL.Vertex2(SelectionBox.RightPoint, SelectionBox.TopPoint);
|
||||
GL.Vertex2(SelectionBox.LeftPoint, SelectionBox.TopPoint);
|
||||
GL.End();
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
}
|
||||
|
||||
if (UseOrtho)
|
||||
@ -234,10 +246,10 @@ namespace Toolbox.Library.Forms
|
||||
UnselectAll();
|
||||
|
||||
SelectedObjects.Add(picks[0]);
|
||||
|
||||
picks[0].IsSelected = true;
|
||||
}
|
||||
|
||||
pickAction = PickAction.Translate;
|
||||
isPicked = true;
|
||||
}
|
||||
else if (Control.ModifierKeys != Keys.Control)
|
||||
@ -252,6 +264,7 @@ namespace Toolbox.Library.Forms
|
||||
{
|
||||
if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Middle)
|
||||
{
|
||||
pickAction = PickAction.None;
|
||||
mouseCameraDown = false;
|
||||
mouseDown = false;
|
||||
isPicked = false;
|
||||
@ -302,6 +315,51 @@ namespace Toolbox.Library.Forms
|
||||
glControl1.Invalidate();
|
||||
}
|
||||
|
||||
if (!showSelectionBox && isPicked)
|
||||
{
|
||||
Console.WriteLine(pickAction);
|
||||
|
||||
RenderEditor();
|
||||
var temp = e.Location;
|
||||
var curPos = OpenGLHelper.convertScreenToWorldCoords(temp.X, temp.Y);
|
||||
var prevPos = OpenGLHelper.convertScreenToWorldCoords(pickOriginMouse.X, pickOriginMouse.Y);
|
||||
var pickMouse = new Point((int)(prevPos.X - curPos.X), (int)(prevPos.Y - curPos.Y));
|
||||
|
||||
Console.WriteLine("curPos " + curPos);
|
||||
Console.WriteLine("prevPos " + prevPos);
|
||||
|
||||
GL.PopMatrix();
|
||||
|
||||
if (pickAction == PickAction.Translate)
|
||||
{
|
||||
foreach (var pickObject in SelectedObjects)
|
||||
{
|
||||
if (pickOriginMouse != Point.Empty)
|
||||
{
|
||||
float posX = 0;
|
||||
float posY = 0;
|
||||
float posZ = 0;
|
||||
|
||||
if (pickAxis == PickAxis.X)
|
||||
posX = pickMouse.X;
|
||||
if (pickAxis == PickAxis.Y)
|
||||
posY = pickMouse.Y;
|
||||
if (pickAxis == PickAxis.All)
|
||||
{
|
||||
posX = pickMouse.X;
|
||||
posY = pickMouse.Y;
|
||||
}
|
||||
|
||||
pickObject.PickTranslate(posX, posY, posZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pickOriginMouse = temp;
|
||||
|
||||
glControl1.Invalidate();
|
||||
}
|
||||
|
||||
if (mouseDown && !isPicked)
|
||||
{
|
||||
RenderEditor();
|
||||
|
@ -62,6 +62,11 @@ namespace Toolbox.Library
|
||||
public static int FontSize = 12;
|
||||
}
|
||||
|
||||
public class MuuntEditor
|
||||
{
|
||||
public static bool Enable3DViewport = false;
|
||||
}
|
||||
|
||||
public class LayoutEditor
|
||||
{
|
||||
public static bool AnimationEditMode = false;
|
||||
|
@ -298,6 +298,9 @@
|
||||
<Compile Include="Forms\Custom\STRadioButton.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Custom\Treeview\TreeviewDragSorter.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Dialogs\ColorSelectorDropdown.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
@ -394,6 +397,7 @@
|
||||
<Compile Include="IO\SubStream.cs" />
|
||||
<Compile Include="OpenGL\GLShaderGeneric.cs" />
|
||||
<Compile Include="OpenGL\IPickableObject.cs" />
|
||||
<Compile Include="OpenGL\OpenGL2DEnums.cs" />
|
||||
<Compile Include="OpenGL\Render2D.cs" />
|
||||
<Compile Include="OpenGL\STRectangle.cs" />
|
||||
<Compile Include="OpenGL\Viewport2D.cs">
|
||||
@ -860,7 +864,7 @@
|
||||
<Compile Include="Forms\Custom\PictureBoxCustom.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Custom\TreeViewCustom.cs" />
|
||||
<Compile Include="Forms\Custom\Treeview\TreeViewCustom.cs" />
|
||||
<Compile Include="Forms\Dialogs\FolderSelectDialog.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
Binary file not shown.
Binary file not shown.
@ -9,5 +9,6 @@ out vec4 FragColor;
|
||||
void main()
|
||||
{
|
||||
vec3 displayNormal = (normal.xyz * 0.5) + 0.5;
|
||||
FragColor = vec4(displayNormal.rgb,1);
|
||||
float shading = max(displayNormal.y,0.5);
|
||||
FragColor = vec4(vec3(shading),1);
|
||||
}
|
||||
|
@ -17,5 +17,5 @@ void main()
|
||||
color = vColor;
|
||||
position = vPosition;
|
||||
|
||||
gl_Position = modelMatrix * modelViewMatrix * vec4(vPosition.xyz, 1.0);
|
||||
gl_Position = modelViewMatrix * vec4(vPosition.xzy, 1.0);
|
||||
}
|
@ -20,7 +20,7 @@ void main()
|
||||
color = vColor;
|
||||
position = vPosition;
|
||||
|
||||
gl_Position = mtxMdl * mtxCam *vec4(vPosition.xyz, 1.0);
|
||||
gl_Position = mtxCam * mtxMdl * vec4(vPosition.xyz, 1.0);
|
||||
|
||||
vec3 distance = (vPosition.xyz + vec3(5, 5, 5))/2;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user