2019-04-06 01:47:21 +02:00
|
|
|
|
using Gl_EditorFramework;
|
|
|
|
|
using GL_EditorFramework.GL_Core;
|
|
|
|
|
using GL_EditorFramework.Interfaces;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using Switch_Toolbox.Library.IO;
|
|
|
|
|
using static GL_EditorFramework.EditorDrawables.EditorSceneBase;
|
2019-04-06 19:46:35 +02:00
|
|
|
|
using FirstPlugin.Turbo.CourseMuuntStructs;
|
2019-04-06 01:47:21 +02:00
|
|
|
|
|
|
|
|
|
namespace GL_EditorFramework.EditorDrawables
|
|
|
|
|
{
|
2019-04-06 19:07:23 +02:00
|
|
|
|
public class RenderablePathPoint : EditableObject
|
2019-04-06 01:47:21 +02:00
|
|
|
|
{
|
2019-04-07 02:16:41 +02:00
|
|
|
|
public bool IsVisable = true;
|
|
|
|
|
|
2019-04-06 21:13:55 +02:00
|
|
|
|
public bool CanConnect = true;
|
|
|
|
|
|
2019-04-06 19:29:42 +02:00
|
|
|
|
public object NodeObject;
|
|
|
|
|
|
2019-04-06 19:07:23 +02:00
|
|
|
|
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);
|
2019-04-06 01:47:21 +02:00
|
|
|
|
|
|
|
|
|
protected Vector3 Normal = new Vector3(0, 0, 0);
|
|
|
|
|
protected Vector3 Tangent = new Vector3(0, 0, 0);
|
|
|
|
|
|
|
|
|
|
protected bool Selected = false;
|
|
|
|
|
|
|
|
|
|
public override bool IsSelected() => Selected;
|
|
|
|
|
|
|
|
|
|
public override bool IsSelected(int partIndex) => Selected;
|
|
|
|
|
|
2019-04-07 02:34:12 +02:00
|
|
|
|
public Vector4 Color = new Vector4(0f, 0.25f, 1f, 1f);
|
2019-04-06 01:47:21 +02:00
|
|
|
|
|
2019-04-07 02:34:12 +02:00
|
|
|
|
public RenderablePathPoint(Vector4 color, Vector3 pos, Vector3 rot, Vector3 sca, object nodeObject) {
|
2019-04-06 19:29:42 +02:00
|
|
|
|
NodeObject = nodeObject;
|
2019-04-07 02:34:12 +02:00
|
|
|
|
|
|
|
|
|
Color = color;
|
2019-04-06 19:07:23 +02:00
|
|
|
|
UpdateTransform(pos, rot, sca);
|
2019-04-06 01:47:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-06 19:07:23 +02:00
|
|
|
|
public RenderablePathPoint(Vector3 pos, Vector3 normal, Vector3 tangent, Vector3 sca) {
|
|
|
|
|
UpdateTransform(pos, normal, tangent, sca);
|
2019-04-06 01:47:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-06 19:07:23 +02:00
|
|
|
|
public void UpdateTransform(Vector3 pos, Vector3 rot, Vector3 sca)
|
2019-04-06 01:47:21 +02:00
|
|
|
|
{
|
2019-04-06 19:07:23 +02:00
|
|
|
|
position = pos;
|
|
|
|
|
rotate = rot;
|
|
|
|
|
scale = new Vector3(sca / 2);
|
2019-04-06 01:47:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateTransform(Vector3 pos, Vector3 normal, Vector3 tangent, Vector3 scale)
|
|
|
|
|
{
|
|
|
|
|
IsNormalTanTransform = true;
|
|
|
|
|
Normal = normal;
|
|
|
|
|
Tangent = tangent;
|
2019-04-06 19:07:23 +02:00
|
|
|
|
scale = new Vector3(scale / 2);
|
2019-04-06 01:47:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Draw(GL_ControlModern control, Pass pass, EditorSceneBase editorScene)
|
|
|
|
|
{
|
2019-04-07 02:16:41 +02:00
|
|
|
|
if (pass == Pass.TRANSPARENT || !IsVisable)
|
2019-04-06 01:47:21 +02:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool hovered = editorScene.hovered == this;
|
|
|
|
|
|
|
|
|
|
if (IsNormalTanTransform)
|
|
|
|
|
{
|
2019-04-06 19:07:23 +02:00
|
|
|
|
control.UpdateModelMatrix(Matrix4.CreateScale(scale) *
|
2019-04-06 01:47:21 +02:00
|
|
|
|
MatrixExenstion.CreateRotation(Normal, Tangent) *
|
|
|
|
|
Matrix4.CreateTranslation(Selected ? editorScene.currentAction.newPos(Position) : Position));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-04-06 19:07:23 +02:00
|
|
|
|
control.UpdateModelMatrix(Matrix4.CreateScale(scale) *
|
|
|
|
|
(Matrix4.CreateRotationX(rotate.X) *
|
|
|
|
|
Matrix4.CreateRotationY(rotate.Y) *
|
|
|
|
|
Matrix4.CreateRotationZ(rotate.Z)) *
|
2019-04-06 01:47:21 +02:00
|
|
|
|
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_ControlModern control, Pass pass)
|
|
|
|
|
{
|
2019-04-07 02:16:41 +02:00
|
|
|
|
if (pass == Pass.TRANSPARENT || !IsVisable)
|
2019-04-06 01:47:21 +02:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
control.UpdateModelMatrix(Matrix4.CreateScale(0.5f) *
|
|
|
|
|
Matrix4.CreateTranslation(position));
|
|
|
|
|
|
|
|
|
|
Renderers.ColorBlockRenderer.Draw(control, pass, Color, Color, control.nextPickingColor());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Draw(GL_ControlLegacy control, Pass pass, EditorSceneBase editorScene)
|
|
|
|
|
{
|
2019-04-07 02:16:41 +02:00
|
|
|
|
if (pass == Pass.TRANSPARENT || !IsVisable)
|
2019-04-06 01:47:21 +02:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool hovered = editorScene.hovered == this;
|
|
|
|
|
|
|
|
|
|
control.UpdateModelMatrix(Matrix4.CreateScale(0.5f) *
|
|
|
|
|
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)
|
|
|
|
|
{
|
2019-04-07 02:16:41 +02:00
|
|
|
|
if (pass == Pass.TRANSPARENT || !IsVisable)
|
2019-04-06 01:47:21 +02:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
control.UpdateModelMatrix(Matrix4.CreateScale(0.5f) *
|
|
|
|
|
Matrix4.CreateTranslation(position));
|
|
|
|
|
|
|
|
|
|
Renderers.ColorBlockRenderer.Draw(control, pass, Color, Color, control.nextPickingColor());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-06 19:07:23 +02:00
|
|
|
|
public override void Prepare(GL_ControlModern control)
|
|
|
|
|
{
|
|
|
|
|
Renderers.ColorBlockRenderer.Initialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Prepare(GL_ControlLegacy control)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void Translate(Vector3 lastPos, Vector3 translate, int subObj)
|
|
|
|
|
{
|
|
|
|
|
position = lastPos + translate;
|
2019-04-06 19:46:35 +02:00
|
|
|
|
UpdateNodePosition();
|
2019-04-06 19:07:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-06 21:13:55 +02:00
|
|
|
|
public virtual void UpdatePosition(int subObj) {
|
2019-04-06 19:07:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool CanStartDragging() => true;
|
|
|
|
|
|
|
|
|
|
public override BoundingBox GetSelectionBox() => new BoundingBox(
|
2019-04-06 19:46:35 +02:00
|
|
|
|
position.X - scale.X,
|
|
|
|
|
position.X + scale.X,
|
|
|
|
|
position.Y - scale.Y,
|
|
|
|
|
position.Y + scale.Y,
|
|
|
|
|
position.Z - scale.Z,
|
|
|
|
|
position.Z + scale.Z
|
2019-04-06 19:07:23 +02:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
public override uint SelectAll(GL_ControlBase control)
|
|
|
|
|
{
|
|
|
|
|
Selected = true;
|
|
|
|
|
return REDRAW;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override uint SelectDefault(GL_ControlBase control)
|
|
|
|
|
{
|
|
|
|
|
Selected = true;
|
|
|
|
|
return REDRAW;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override uint Select(int partIndex, GL_ControlBase control)
|
|
|
|
|
{
|
|
|
|
|
Selected = true;
|
|
|
|
|
return REDRAW;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override uint Deselect(int partIndex, GL_ControlBase control)
|
|
|
|
|
{
|
|
|
|
|
Selected = false;
|
|
|
|
|
return REDRAW;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override uint DeselectAll(GL_ControlBase control)
|
|
|
|
|
{
|
|
|
|
|
Selected = false;
|
|
|
|
|
return REDRAW;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-06 01:47:21 +02:00
|
|
|
|
public override void ApplyTransformActionToSelection(AbstractTransformAction transformAction)
|
|
|
|
|
{
|
2019-04-06 19:07:23 +02:00
|
|
|
|
position = transformAction.newPos(position);
|
2019-04-06 19:46:35 +02:00
|
|
|
|
UpdateNodePosition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateNodePosition()
|
|
|
|
|
{
|
|
|
|
|
if (NodeObject is PathPoint)
|
|
|
|
|
{
|
|
|
|
|
((PathPoint)NodeObject).Translate = position;
|
|
|
|
|
((PathPoint)NodeObject).Scale = scale;
|
|
|
|
|
((PathPoint)NodeObject).Rotate = rotate;
|
2019-04-06 21:13:55 +02:00
|
|
|
|
|
|
|
|
|
if (((PathPoint)NodeObject).OnPathMoved != null)
|
|
|
|
|
((PathPoint)NodeObject).OnPathMoved();
|
2019-04-06 19:46:35 +02:00
|
|
|
|
}
|
2019-04-06 19:07:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Vector3 Position
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return position;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
position = value;
|
|
|
|
|
}
|
2019-04-06 01:47:21 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|