From fb5c0e08d09f4e78626082423ada5768511b8207 Mon Sep 17 00:00:00 2001
From: miku-666 <74728189+NessieHax@users.noreply.github.com>
Date: Sun, 1 Oct 2023 12:48:28 +0200
Subject: [PATCH] Removed Classes/Models folder, reworked SKinPreview.cs,
renamed MouseRay to Ray and changed Renderer3D member names
---
PCK-Studio/Classes/Models/BackgroundTypes.cs | 11 -
PCK-Studio/Classes/Models/Backgrounds.cs | 14 -
PCK-Studio/Classes/Models/Box.cs | 158 -----
.../Classes/Models/DefaultModels/ModelBase.cs | 59 --
.../Models/DefaultModels/Steve64x32Model.cs | 88 ---
.../Models/DefaultModels/Steve64x64Model.cs | 122 ----
PCK-Studio/Classes/Models/Effects.cs | 12 -
PCK-Studio/Classes/Models/Matrix3D.cs | 177 ------
.../Classes/Models/ModelView.Designer.cs | 73 ---
PCK-Studio/Classes/Models/ModelView.cs | 431 -------------
PCK-Studio/Classes/Models/Object3D.cs | 461 --------------
PCK-Studio/Classes/Models/Object3DGroup.cs | 65 --
PCK-Studio/Classes/Models/Point3D.cs | 31 -
PCK-Studio/Classes/Models/Positions.cs | 14 -
PCK-Studio/Classes/Models/ProjectionTypes.cs | 10 -
PCK-Studio/Classes/Models/RotationOrders.cs | 14 -
PCK-Studio/Classes/Models/Texel.cs | 49 --
PCK-Studio/Classes/Models/TexelComparer.cs | 17 -
PCK-Studio/Classes/Models/TexturePlane.cs | 189 ------
.../Classes/Utils/{MouseRay.cs => Ray.cs} | 232 ++++---
.../SkinPreview.Designer.cs | 11 +-
.../Forms/Skins-And-Textures/SkinPreview.cs | 30 +-
PCK-Studio/Forms/TestGL.Designer.cs | 24 +-
PCK-Studio/Forms/TestGL.cs | 11 +-
PCK-Studio/MainForm.cs | 2 +-
PCK-Studio/PckStudio.csproj | 39 +-
.../Renderer3D.Designer.cs | 52 +-
.../{ToolboxItems => Rendering}/Renderer3D.cs | 599 ++++++++----------
28 files changed, 438 insertions(+), 2557 deletions(-)
delete mode 100644 PCK-Studio/Classes/Models/BackgroundTypes.cs
delete mode 100644 PCK-Studio/Classes/Models/Backgrounds.cs
delete mode 100644 PCK-Studio/Classes/Models/Box.cs
delete mode 100644 PCK-Studio/Classes/Models/DefaultModels/ModelBase.cs
delete mode 100644 PCK-Studio/Classes/Models/DefaultModels/Steve64x32Model.cs
delete mode 100644 PCK-Studio/Classes/Models/DefaultModels/Steve64x64Model.cs
delete mode 100644 PCK-Studio/Classes/Models/Effects.cs
delete mode 100644 PCK-Studio/Classes/Models/Matrix3D.cs
delete mode 100644 PCK-Studio/Classes/Models/ModelView.Designer.cs
delete mode 100644 PCK-Studio/Classes/Models/ModelView.cs
delete mode 100644 PCK-Studio/Classes/Models/Object3D.cs
delete mode 100644 PCK-Studio/Classes/Models/Object3DGroup.cs
delete mode 100644 PCK-Studio/Classes/Models/Point3D.cs
delete mode 100644 PCK-Studio/Classes/Models/Positions.cs
delete mode 100644 PCK-Studio/Classes/Models/ProjectionTypes.cs
delete mode 100644 PCK-Studio/Classes/Models/RotationOrders.cs
delete mode 100644 PCK-Studio/Classes/Models/Texel.cs
delete mode 100644 PCK-Studio/Classes/Models/TexelComparer.cs
delete mode 100644 PCK-Studio/Classes/Models/TexturePlane.cs
rename PCK-Studio/Classes/Utils/{MouseRay.cs => Ray.cs} (65%)
rename PCK-Studio/{ToolboxItems => Rendering}/Renderer3D.Designer.cs (53%)
rename PCK-Studio/{ToolboxItems => Rendering}/Renderer3D.cs (86%)
diff --git a/PCK-Studio/Classes/Models/BackgroundTypes.cs b/PCK-Studio/Classes/Models/BackgroundTypes.cs
deleted file mode 100644
index b460d046..00000000
--- a/PCK-Studio/Classes/Models/BackgroundTypes.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-
-namespace PckStudio.Models
-{
- public enum BackgroundTypes
- {
- Color,
- Gradient,
- Texture
- }
-}
diff --git a/PCK-Studio/Classes/Models/Backgrounds.cs b/PCK-Studio/Classes/Models/Backgrounds.cs
deleted file mode 100644
index 692896bc..00000000
--- a/PCK-Studio/Classes/Models/Backgrounds.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-
-namespace PckStudio.Models
-{
- public enum Backgrounds
- {
- LightStone,
- DarkStone,
- DaySky,
- NightSky,
- Sunset,
- Transparent
- }
-}
diff --git a/PCK-Studio/Classes/Models/Box.cs b/PCK-Studio/Classes/Models/Box.cs
deleted file mode 100644
index 23d64a9d..00000000
--- a/PCK-Studio/Classes/Models/Box.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-using System;
-using System.Drawing;
-
-namespace PckStudio.Models
-{
- public class Box : Object3D
- {
- public override Image Image
- {
- set
- {
- SetImage(value);
- }
- }
-
- internal override MinecraftModelView Viewport
- {
- set
- {
- base.Viewport = value;
- top.Viewport = value;
- bottom.Viewport = value;
- front.Viewport = value;
- back.Viewport = value;
- left.Viewport = value;
- right.Viewport = value;
- Update();
- }
- }
-
- internal override void Update()
- {
- Matrix3D a = globalTransformation * localTransformation;
- top.LocalTransformation = a * topLocalTransformation;
- bottom.LocalTransformation = a * bottomLocalTransformation;
- front.LocalTransformation = a * frontLocalTransformation;
- back.LocalTransformation = a * backLocalTransformation;
- left.LocalTransformation = a * leftLocalTransformation;
- right.LocalTransformation = a * rightLocalTransformation;
- }
-
- public Box(Image image, Rectangle srcTopBottom, Rectangle srcSides, Point3D origin, Effects effects = Effects.None)
- {
- this.effects = effects;
- Origin = origin;
- SetImage(image, srcTopBottom, srcSides);
- }
-
- private void SetImage(Image image, Rectangle srcTopBottom, Rectangle srcSides)
- {
- int num = srcTopBottom.Width / 2;
- int height = srcSides.Height;
- int height2 = srcTopBottom.Height;
- srcTop = new Rectangle(srcTopBottom.Location, new Size(num, height2));
- srcBottom = new Rectangle(srcTopBottom.X + num, srcTopBottom.Y, num, height2);
- srcFront = new Rectangle(srcSides.X + height2, srcSides.Y, num, height);
- srcBack = new Rectangle(srcSides.X + height2 + num + height2, srcSides.Y, num, height);
- srcLeft = new Rectangle(srcSides.Location, new Size(height2, height));
- srcRight = new Rectangle(srcSides.X + height2 + num, srcSides.Y, height2, height);
- SetImage(image);
- }
-
- private void SetImage(Image image)
- {
- bool flag = (byte)(effects & Effects.FlipHorizontally) == 1;
- bool flag2 = (byte)(effects & Effects.FlipVertically) == 2;
- int width = srcFront.Width;
- int height = srcFront.Height;
- int width2 = srcLeft.Width;
- top = new TexturePlane(image, flag2 ? srcBottom : srcTop, new Point3D(width * 0.5f, width2 * 0.5f, (float)(-(float)height) * 0.5f), new Point3D(0f, 1f, 0f), effects & Effects.FlipHorizontally);
- bottom = new TexturePlane(image, flag2 ? srcTop : srcBottom, new Point3D(width / 2f, width2 / 2f, height / 2f), new Point3D(0f, -1f, 0f), effects & Effects.FlipHorizontally);
- front = new TexturePlane(image, srcFront, new Point3D(width * 0.5f, height * 0.5f, (float)(-(float)width2) * 0.5f), new Point3D(0f, 0f, 1f), effects);
- back = new TexturePlane(image, srcBack, new Point3D(width * 0.5f, height * 0.5f, (float)(-(float)width2) * 0.5f), new Point3D(0f, 0f, -1f), effects);
- left = new TexturePlane(image, flag ? srcRight : srcLeft, new Point3D(width2 * 0.5f, height * 0.5f, (float)(-(float)width) * 0.5f), new Point3D(-1f, 0f, 0f), effects);
- right = new TexturePlane(image, flag ? srcLeft : srcRight, new Point3D(width2 * 0.5f, height * 0.5f, (float)(-(float)width) * 0.5f), new Point3D(1f, 0f, 0f), effects);
- top.Viewport = viewport;
- bottom.Viewport = viewport;
- front.Viewport = viewport;
- back.Viewport = viewport;
- left.Viewport = viewport;
- right.Viewport = viewport;
- }
-
- public override float HitTest(PointF location)
- {
- float num = -1000f;
- float num2 = top.HitTest(location);
- if (num2 > num)
- {
- num = num2;
- }
- num2 = bottom.HitTest(location);
- if (num2 > num)
- {
- num = num2;
- }
- num2 = front.HitTest(location);
- if (num2 > num)
- {
- num = num2;
- }
- num2 = back.HitTest(location);
- if (num2 > num)
- {
- num = num2;
- }
- num2 = left.HitTest(location);
- if (num2 > num)
- {
- num = num2;
- }
- num2 = right.HitTest(location);
- if (num2 > num)
- {
- num = num2;
- }
- return num;
- }
-
- private TexturePlane top;
-
- private TexturePlane bottom;
-
- private TexturePlane front;
-
- private TexturePlane back;
-
- private TexturePlane left;
-
- private TexturePlane right;
-
- private Rectangle srcTop;
-
- private Rectangle srcBottom;
-
- private Rectangle srcFront;
-
- private Rectangle srcBack;
-
- private Rectangle srcLeft;
-
- private Rectangle srcRight;
-
- private Matrix3D topLocalTransformation = Matrix3D.CreateRotationX(-1.57079637f);
-
- private Matrix3D bottomLocalTransformation = Matrix3D.CreateRotationX(-1.57079637f);
-
- private Matrix3D frontLocalTransformation = Matrix3D.Identity;
-
- private Matrix3D backLocalTransformation = Matrix3D.CreateRotationY(3.14159274f);
-
- private Matrix3D leftLocalTransformation = Matrix3D.CreateRotationY(-1.57079637f);
-
- private Matrix3D rightLocalTransformation = Matrix3D.CreateRotationY(1.57079637f);
-
- private Effects effects;
- }
-}
diff --git a/PCK-Studio/Classes/Models/DefaultModels/ModelBase.cs b/PCK-Studio/Classes/Models/DefaultModels/ModelBase.cs
deleted file mode 100644
index 66a759c9..00000000
--- a/PCK-Studio/Classes/Models/DefaultModels/ModelBase.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using System;
-using PckStudio.Models;
-using System.Runtime.CompilerServices;
-using System.Threading;
-using System.Drawing;
-
-namespace PckStudio.Models
-{
- public abstract class ModelBase
- {
- public ModelBase()
- { }
-
- protected Image[] textures;
-
- public EventHandler OnUpdate;
- protected const float OverlayScale = 1.16f;
-
- public Image[] Textures => textures;
-
- public event EventHandler Updatedx
- {
- add
- {
- EventHandler eventHandler = OnUpdate;
- EventHandler eventHandler2;
- do
- {
- eventHandler2 = eventHandler;
- EventHandler value2 = (EventHandler)Delegate.Combine(eventHandler2, value);
- eventHandler = Interlocked.CompareExchange(ref OnUpdate, value2, eventHandler2);
- }
- while (eventHandler != eventHandler2);
- }
- remove
- {
- EventHandler eventHandler = OnUpdate;
- EventHandler eventHandler2;
- do
- {
- eventHandler2 = eventHandler;
- EventHandler value2 = (EventHandler)Delegate.Remove(eventHandler2, value);
- eventHandler = Interlocked.CompareExchange(ref OnUpdate, value2, eventHandler2);
- }
- while (eventHandler != eventHandler2);
- }
- }
-
- protected void OnUpdated()
- {
- if (OnUpdate != null)
- {
- OnUpdate(this, EventArgs.Empty);
- }
- }
-
- public abstract void AddToModelView(MinecraftModelView modelView);
- }
-}
diff --git a/PCK-Studio/Classes/Models/DefaultModels/Steve64x32Model.cs b/PCK-Studio/Classes/Models/DefaultModels/Steve64x32Model.cs
deleted file mode 100644
index 0af00dfc..00000000
--- a/PCK-Studio/Classes/Models/DefaultModels/Steve64x32Model.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using System;
-using System.IO;
-using System.Drawing;
-using PckStudio.Models;
-using PckStudio.Properties;
-
-namespace PckStudio.Models
-{
- internal class Steve64x32Model : ModelBase
- {
- public Steve64x32Model(Image texture)
- {
- textures = new Image[1] { texture };
- }
-
- public override void AddToModelView(MinecraftModelView modelView)
- {
- _ = Textures[0] ?? throw new NullReferenceException(nameof(Textures));
- Image source = Textures[0];
- Box head = new Box(source, new Rectangle( 8, 0, 16, 8), new Rectangle( 0, 8, 32, 8), new Point3D(0f, 0f, 0f));
- Box headOverlay = new Box(source, new Rectangle(40, 0, 16, 8), new Rectangle(32, 8, 32, 8), new Point3D(0f, 0f, 0f));
- headOverlay.Scale = OverlayScale;
-
- Box body = new Box(source, new Rectangle(20, 16, 16, 4), new Rectangle(16, 20, 24, 12), new Point3D(0f, 0f, 0f));
-
- Box leftArm = new Box(source, new Rectangle(44, 16, 8, 4), new Rectangle(40, 20, 32, 12), new Point3D(0f, 4f, 0f));
- Box rightArm = new Box(source, new Rectangle(44, 16, 8, 4), new Rectangle(40, 20, 32, 12), new Point3D(0f, 4f, 0f));
-
- Box leftLeg = new Box(source, new Rectangle(4, 16, 8, 4), new Rectangle(0, 20, 16, 12), new Point3D(0f, 6f, 0f));
- Box rightLeg = new Box(source, new Rectangle(4, 16, 8, 4), new Rectangle(0, 20, 16, 12), new Point3D(0f, 6f, 0f));
-
- Object3DGroup headGroup = new Object3DGroup();
-
- headGroup.RotationOrder = RotationOrders.XY;
- headGroup.MinDegrees1 = -80f;
- headGroup.MaxDegrees1 = 80f;
-
- headGroup.MinDegrees2 = -57f;
- headGroup.MaxDegrees2 = 57f;
-
- headGroup.Add(head);
- headGroup.Add(headOverlay);
-
- headGroup.Position = new Point3D(0f, 8f, 0f);
- headGroup.Origin = new Point3D(0f, -4f, 0f);
- headGroup.RotationOrder = RotationOrders.XY;
-
- body.Position = new Point3D(0f, 2f, 0f);
-
- leftArm.Position = new Point3D(6f, 6f, 0f);
- leftArm.RotationOrder = RotationOrders.ZX;
- leftArm.MinDegrees1 = 0f;
- leftArm.MaxDegrees1 = 160f;
- leftArm.MinDegrees2 = -170f;
- leftArm.MaxDegrees2 = 60f;
-
- rightArm.Position = new Point3D(-6f, 6f, 0f);
- rightArm.RotationOrder = RotationOrders.ZX;
- rightArm.MinDegrees1 = -160f;
- rightArm.MaxDegrees1 = 0f;
- rightArm.MinDegrees2 = -170f;
- rightArm.MaxDegrees2 = 60f;
-
- leftLeg.Position = new Point3D(2f, -4f, 0f);
- leftLeg.RotationOrder = RotationOrders.ZX;
- leftLeg.MinDegrees1 = 0f;
- leftLeg.MaxDegrees1 = 70f;
- leftLeg.MinDegrees2 = -110f;
- leftLeg.MaxDegrees2 = 60f;
-
- rightLeg.Position = new Point3D(-2f, -4f, 0f);
- rightLeg.RotationOrder = RotationOrders.ZX;
- rightLeg.MinDegrees1 = -70f;
- rightLeg.MaxDegrees1 = 0f;
- rightLeg.MinDegrees2 = -110f;
- rightLeg.MaxDegrees2 = 60f;
-
- modelView.AddDynamic(headGroup);
- modelView.AddStatic(body);
- modelView.AddDynamic(rightArm);
- modelView.AddDynamic(leftArm);
- modelView.AddDynamic(rightLeg);
- modelView.AddDynamic(leftLeg);
- }
-
- public override string ToString() => nameof(Steve64x32Model);
- }
-}
diff --git a/PCK-Studio/Classes/Models/DefaultModels/Steve64x64Model.cs b/PCK-Studio/Classes/Models/DefaultModels/Steve64x64Model.cs
deleted file mode 100644
index e7442333..00000000
--- a/PCK-Studio/Classes/Models/DefaultModels/Steve64x64Model.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-using System.Security.Policy;
-using System.Text;
-using System.Threading.Tasks;
-using PckStudio.Internal;
-using PckStudio.Models;
-
-namespace PckStudio.Classes.Models.DefaultModels
-{
- internal class Steve64x64Model : ModelBase
- {
- SkinANIM _skinANIM;
- public Steve64x64Model(Image texture, SkinANIM anim)
- {
- textures = new Image[1] { texture };
- _skinANIM = anim;
- }
-
- public override void AddToModelView(MinecraftModelView modelView)
- {
- _ = Textures[0] ?? throw new NullReferenceException(nameof(Textures));
- Image source = Textures[0];
-
- (int top, int side) armWidth = _skinANIM.GetFlag(SkinAnimFlag.SLIM_MODEL) ? (6, 14) : (8, 16);
-
- Box head = new Box(source, new Rectangle(8, 0, 16, 8), new Rectangle(0, 8, 32, 8), new Point3D(0f, 0f, 0f));
- Box headOverlay = new Box(source, new Rectangle(40, 0, 16, 8), new Rectangle(32, 8, 32, 8), new Point3D(0f, 0f, 0f));
- headOverlay.Scale = OverlayScale;
-
- Box body = new Box(source, new Rectangle(20, 16, 16, 4), new Rectangle(16, 20, 24, 12), new Point3D(0f, 0f, 0f));
- Box bodyOverlay = new Box(source, new Rectangle(20, 32, 16, 4), new Rectangle(16, 36, 24, 12), new Point3D(0f, 0f, 0f));
- bodyOverlay.Scale = OverlayScale;
-
- Box rightArm = new Box(source, new Rectangle(44, 16, armWidth.top, 4), new Rectangle(40, 20, armWidth.side, 12), new Point3D(0f, 4f, 0f));
- Box rightArmOverlay = new Box(source, new Rectangle(44, 32, armWidth.top, 4), new Rectangle(40, 36, armWidth.side, 12), new Point3D(0f, 4f, 0f));
- rightArmOverlay.Scale = OverlayScale;
-
- Box leftArm = new Box(source, new Rectangle(36, 48, armWidth.top, 4), new Rectangle(32, 52, armWidth.side, 12), new Point3D(0f, 4f, 0f));
- Box leftArmOverlay = new Box(source, new Rectangle(52, 48, armWidth.top, 4), new Rectangle(48, 52, armWidth.side, 12), new Point3D(0f, 4f, 0f));
- leftArmOverlay.Scale = OverlayScale;
-
- Box rightLeg = new Box(source, new Rectangle(4, 16, 8, 4), new Rectangle(0, 20, 16, 12), new Point3D(0f, 6f, 0f));
- Box rightLegOverlay = new Box(source, new Rectangle(4, 32, 8, 4), new Rectangle(0, 52, 16, 12), new Point3D(0f, 6f, 0f));
- rightLegOverlay.Scale = OverlayScale;
-
- Box leftLeg = new Box(source, new Rectangle(20, 48, 8, 4), new Rectangle(16, 52, 16, 12), new Point3D(0f, 6f, 0f));
- Box leftLegOverlay = new Box(source, new Rectangle( 4, 48, 8, 4), new Rectangle( 0, 52, 16, 12), new Point3D(0f, 6f, 0f));
- leftLegOverlay.Scale = OverlayScale;
-
- Object3DGroup headGroup = new Object3DGroup();
- Object3DGroup bodyGroup = new Object3DGroup();
- Object3DGroup leftArmGroup = new Object3DGroup();
- Object3DGroup rightArmGroup = new Object3DGroup();
- Object3DGroup leftLegGroup = new Object3DGroup();
- Object3DGroup rightLegGroup = new Object3DGroup();
-
- headGroup.RotationOrder = RotationOrders.XY;
- headGroup.MinDegrees1 = -80f;
- headGroup.MaxDegrees1 = 80f;
-
- headGroup.MinDegrees2 = -57f;
- headGroup.MaxDegrees2 = 57f;
-
- headGroup.Origin = new Point3D(0f, -4f, 0f);
- headGroup.RotationOrder = RotationOrders.XY;
-
- headGroup.Position = new Point3D(0f, 8f, 0f);
- headGroup.Add(head);
- headGroup.Add(headOverlay);
-
- bodyGroup.Position = new Point3D(0f, 2f, 0f);
- bodyGroup.Add(body);
- bodyGroup.Add(bodyOverlay);
-
- leftArmGroup.Position = new Point3D(6f, 6f, 0f);
- leftArmGroup.RotationOrder = RotationOrders.ZX;
- leftArmGroup.MinDegrees1 = 0f;
- leftArmGroup.MaxDegrees1 = 160f;
- leftArmGroup.MinDegrees2 = -170f;
- leftArmGroup.MaxDegrees2 = 60f;
- leftArmGroup.Add(leftArm);
- leftArmGroup.Add(leftArmOverlay);
-
- rightArmGroup.Position = new Point3D(-6f, 6f, 0f);
- rightArmGroup.RotationOrder = RotationOrders.ZX;
- rightArmGroup.MinDegrees1 = -160f;
- rightArmGroup.MaxDegrees1 = 0f;
- rightArmGroup.MinDegrees2 = -170f;
- rightArmGroup.MaxDegrees2 = 60f;
- rightArmGroup.Add(rightArm);
- rightArmGroup.Add(rightArmOverlay);
-
- leftLegGroup.Position = new Point3D(2f, -4f, 0f);
- leftLegGroup.RotationOrder = RotationOrders.ZX;
- leftLegGroup.MinDegrees1 = 0f;
- leftLegGroup.MaxDegrees1 = 70f;
- leftLegGroup.MinDegrees2 = -110f;
- leftLegGroup.MaxDegrees2 = 60f;
- leftLegGroup.Add(leftLeg);
- leftLegGroup.Add(leftLegOverlay);
-
- rightLegGroup.Position = new Point3D(-2f, -4f, 0f);
- rightLegGroup.RotationOrder = RotationOrders.ZX;
- rightLegGroup.MinDegrees1 = -70f;
- rightLegGroup.MaxDegrees1 = 0f;
- rightLegGroup.MinDegrees2 = -110f;
- rightLegGroup.MaxDegrees2 = 60f;
- rightLegGroup.Add(rightLeg);
- rightLegGroup.Add(rightLegOverlay);
-
- modelView.AddDynamic(headGroup);
- modelView.AddStatic(bodyGroup);
- modelView.AddDynamic(rightArmGroup);
- modelView.AddDynamic(leftArmGroup);
- modelView.AddDynamic(rightLegGroup);
- modelView.AddDynamic(leftLegGroup);
- }
- }
-}
diff --git a/PCK-Studio/Classes/Models/Effects.cs b/PCK-Studio/Classes/Models/Effects.cs
deleted file mode 100644
index 418101b2..00000000
--- a/PCK-Studio/Classes/Models/Effects.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-
-namespace PckStudio.Models
-{
- [Flags]
- public enum Effects : byte
- {
- None = 0,
- FlipHorizontally = 1,
- FlipVertically = 2
- }
-}
diff --git a/PCK-Studio/Classes/Models/Matrix3D.cs b/PCK-Studio/Classes/Models/Matrix3D.cs
deleted file mode 100644
index 071528dd..00000000
--- a/PCK-Studio/Classes/Models/Matrix3D.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-using System;
-
-namespace PckStudio.Models
-{
- public struct Matrix3D
- {
- public Matrix3D(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
- {
- M11 = m11;
- M12 = m12;
- M13 = m13;
- M14 = m14;
- M21 = m21;
- M22 = m22;
- M23 = m23;
- M24 = m24;
- M31 = m31;
- M32 = m32;
- M33 = m33;
- M34 = m34;
- M41 = m41;
- M42 = m42;
- M43 = m43;
- M44 = m44;
- }
-
- public static Matrix3D CreateRotationX(float radians)
- {
- float num = (float)Math.Sin((double)radians);
- float num2 = (float)Math.Cos((double)radians);
- return new Matrix3D(1f, 0f, 0f, 0f, 0f, num2, -num, 0f, 0f, num, num2, 0f, 0f, 0f, 0f, 1f);
- }
-
- public static Matrix3D CreateRotationX(float sin, float cos)
- {
- return new Matrix3D(1f, 0f, 0f, 0f, 0f, cos, -sin, 0f, 0f, sin, cos, 0f, 0f, 0f, 0f, 1f);
- }
-
- public static Matrix3D CreateRotationY(float radians)
- {
- float num = (float)Math.Sin((double)radians);
- float num2 = (float)Math.Cos((double)radians);
- return new Matrix3D(num2, 0f, num, 0f, 0f, 1f, 0f, 0f, -num, 0f, num2, 0f, 0f, 0f, 0f, 1f);
- }
-
- public static Matrix3D CreateRotationY(float sin, float cos)
- {
- return new Matrix3D(cos, 0f, sin, 0f, 0f, 1f, 0f, 0f, -sin, 0f, cos, 0f, 0f, 0f, 0f, 1f);
- }
-
- public static Matrix3D CreateRotationZ(float radians)
- {
- float num = (float)Math.Sin((double)radians);
- float num2 = (float)Math.Cos((double)radians);
- return new Matrix3D(num2, -num, 0f, 0f, num, num2, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f);
- }
-
- public static Matrix3D CreateRotationZ(float sin, float cos)
- {
- return new Matrix3D(cos, -sin, 0f, 0f, sin, cos, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f);
- }
-
- public static Matrix3D CreateTranslation(float x, float y, float z)
- {
- return new Matrix3D(1f, 0f, 0f, x, 0f, 1f, 0f, y, 0f, 0f, 1f, z, 0f, 0f, 0f, 1f);
- }
-
- public static Matrix3D CreateTranslation(Point3D point)
- {
- return new Matrix3D(1f, 0f, 0f, point.X, 0f, 1f, 0f, point.Y, 0f, 0f, 1f, point.Z, 0f, 0f, 0f, 1f);
- }
-
- public static Matrix3D CreateScale(float s)
- {
- return new Matrix3D(s, 0f, 0f, 0f, 0f, s, 0f, 0f, 0f, 0f, s, 0f, 0f, 0f, 0f, 1f);
- }
-
- public float Determinant
- {
- get
- {
- return M11 * M22 * M33 * M44 + M21 * M32 * M43 * M14 + M31 * M42 * M13 * M24 + M41 * M12 * M23 * M34 - M14 * M23 * M32 * M41 - M24 * M33 * M42 * M11 - M34 * M43 * M12 * M21 - M44 * M13 * M22 * M31;
- }
- }
-
- public static Matrix3D Identity
- {
- get
- {
- return new Matrix3D(1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f);
- }
- }
-
- public static Matrix3D Transpose(Matrix3D m)
- {
- return new Matrix3D(m.M11, m.M21, m.M31, m.M41, m.M12, m.M22, m.M32, m.M42, m.M13, m.M23, m.M33, m.M43, m.M14, m.M24, m.M34, m.M44);
- }
-
- public static Matrix3D Invert(Matrix3D m)
- {
- float determinant = m.Determinant;
- return new Matrix3D((m.M22 * m.M33 * m.M44 + m.M32 * m.M43 * m.M24 + m.M42 * m.M23 * m.M34 - m.M24 * m.M33 * m.M42 - m.M34 * m.M43 * m.M22 - m.M44 * m.M23 * m.M32) / determinant, -(m.M12 * m.M33 * m.M44 + m.M32 * m.M43 * m.M14 + m.M42 * m.M13 * m.M34 - m.M14 * m.M33 * m.M42 - m.M34 * m.M43 * m.M12 - m.M44 * m.M13 * m.M32) / determinant, (m.M12 * m.M23 * m.M44 + m.M22 * m.M43 * m.M14 + m.M42 * m.M13 * m.M24 - m.M14 * m.M23 * m.M42 - m.M24 * m.M43 * m.M12 - m.M44 * m.M13 * m.M22) / determinant, -(m.M12 * m.M23 * m.M34 + m.M22 * m.M33 * m.M14 + m.M32 * m.M13 * m.M24 - m.M14 * m.M23 * m.M32 - m.M24 * m.M33 * m.M12 - m.M34 * m.M13 * m.M22) / determinant, -(m.M21 * m.M33 * m.M44 + m.M31 * m.M43 * m.M24 + m.M41 * m.M23 * m.M34 - m.M24 * m.M33 * m.M41 - m.M34 * m.M43 * m.M21 - m.M44 * m.M23 * m.M31) / determinant, (m.M11 * m.M33 * m.M44 + m.M31 * m.M43 * m.M14 + m.M41 * m.M13 * m.M34 - m.M14 * m.M33 * m.M41 - m.M34 * m.M43 * m.M11 - m.M44 * m.M13 * m.M31) / determinant, -(m.M11 * m.M23 * m.M44 + m.M21 * m.M43 * m.M14 + m.M41 * m.M13 * m.M24 - m.M14 * m.M23 * m.M41 - m.M24 * m.M43 * m.M11 - m.M44 * m.M13 * m.M21) / determinant, (m.M11 * m.M23 * m.M34 + m.M21 * m.M33 * m.M14 + m.M31 * m.M13 * m.M24 - m.M14 * m.M23 * m.M31 - m.M24 * m.M33 * m.M11 - m.M34 * m.M13 * m.M21) / determinant, (m.M21 * m.M32 * m.M44 + m.M31 * m.M42 * m.M24 + m.M41 * m.M22 * m.M34 - m.M24 * m.M32 * m.M41 - m.M34 * m.M42 * m.M21 - m.M44 * m.M22 * m.M31) / determinant, -(m.M11 * m.M32 * m.M44 + m.M31 * m.M42 * m.M14 + m.M41 * m.M12 * m.M34 - m.M14 * m.M32 * m.M41 - m.M34 * m.M42 * m.M11 - m.M44 * m.M12 * m.M31) / determinant, (m.M11 * m.M32 * m.M44 + m.M21 * m.M42 * m.M14 + m.M41 * m.M12 * m.M24 - m.M14 * m.M22 * m.M41 - m.M24 * m.M42 * m.M11 - m.M44 * m.M12 * m.M21) / determinant, -(m.M11 * m.M22 * m.M34 + m.M21 * m.M32 * m.M14 + m.M31 * m.M12 * m.M24 - m.M14 * m.M22 * m.M31 - m.M24 * m.M32 * m.M11 - m.M34 * m.M12 * m.M21) / determinant, -(m.M21 * m.M32 * m.M43 + m.M31 * m.M42 * m.M23 + m.M41 * m.M22 * m.M33 - m.M23 * m.M32 * m.M41 - m.M33 * m.M42 * m.M21 - m.M43 * m.M22 * m.M31) / determinant, (m.M11 * m.M32 * m.M43 + m.M31 * m.M42 * m.M13 + m.M41 * m.M12 * m.M33 - m.M13 * m.M32 * m.M41 - m.M33 * m.M42 * m.M11 - m.M43 * m.M12 * m.M31) / determinant, -(m.M11 * m.M22 * m.M43 + m.M21 * m.M42 * m.M13 + m.M41 * m.M12 * m.M23 - m.M13 * m.M22 * m.M41 - m.M23 * m.M42 * m.M11 - m.M43 * m.M12 * m.M21) / determinant, (m.M11 * m.M22 * m.M33 + m.M21 * m.M32 * m.M13 + m.M31 * m.M12 * m.M23 - m.M13 * m.M22 * m.M31 - m.M23 * m.M32 * m.M11 - m.M33 * m.M12 * m.M21) / determinant);
- }
-
- public static Matrix3D operator +(Matrix3D a, Matrix3D b)
- {
- return new Matrix3D(a.M11 + b.M11, a.M12 + b.M12, a.M13 + b.M13, a.M14 + b.M14, a.M21 + b.M21, a.M22 + b.M22, a.M23 + b.M23, a.M24 + b.M24, a.M31 + b.M31, a.M32 + b.M32, a.M33 + b.M33, a.M34 + b.M34, a.M41 + b.M41, a.M42 + b.M42, a.M43 + b.M43, a.M44 + b.M44);
- }
-
- public static Matrix3D operator -(Matrix3D a, Matrix3D b)
- {
- return new Matrix3D(a.M11 - b.M11, a.M12 - b.M12, a.M13 - b.M13, a.M14 - b.M14, a.M21 - b.M21, a.M22 - b.M22, a.M23 - b.M23, a.M24 - b.M24, a.M31 - b.M31, a.M32 - b.M32, a.M33 - b.M33, a.M34 - b.M34, a.M41 - b.M41, a.M42 - b.M42, a.M43 - b.M43, a.M44 - b.M44);
- }
-
- public static Matrix3D operator *(Matrix3D a, Matrix3D b)
- {
- return new Matrix3D(a.M11 * b.M11 + a.M12 * b.M21 + a.M13 * b.M31 + a.M14 * b.M41, a.M11 * b.M12 + a.M12 * b.M22 + a.M13 * b.M32 + a.M14 * b.M42, a.M11 * b.M13 + a.M12 * b.M23 + a.M13 * b.M33 + a.M14 * b.M43, a.M11 * b.M14 + a.M12 * b.M24 + a.M13 * b.M34 + a.M14 * b.M44, a.M21 * b.M11 + a.M22 * b.M21 + a.M23 * b.M31 + a.M24 * b.M41, a.M21 * b.M12 + a.M22 * b.M22 + a.M23 * b.M32 + a.M24 * b.M42, a.M21 * b.M13 + a.M22 * b.M23 + a.M23 * b.M33 + a.M24 * b.M43, a.M21 * b.M14 + a.M22 * b.M24 + a.M23 * b.M34 + a.M24 * b.M44, a.M31 * b.M11 + a.M32 * b.M21 + a.M33 * b.M31 + a.M34 * b.M41, a.M31 * b.M12 + a.M32 * b.M22 + a.M33 * b.M32 + a.M34 * b.M42, a.M31 * b.M13 + a.M32 * b.M23 + a.M33 * b.M33 + a.M34 * b.M43, a.M31 * b.M14 + a.M32 * b.M24 + a.M33 * b.M34 + a.M34 * b.M44, a.M41 * b.M11 + a.M42 * b.M21 + a.M43 * b.M31 + a.M44 * b.M41, a.M41 * b.M12 + a.M42 * b.M22 + a.M43 * b.M32 + a.M44 * b.M42, a.M41 * b.M13 + a.M42 * b.M23 + a.M43 * b.M33 + a.M44 * b.M43, a.M41 * b.M14 + a.M42 * b.M24 + a.M43 * b.M34 + a.M44 * b.M44);
- }
-
- public static Point3D operator *(Matrix3D m, Point3D p)
- {
- return new Point3D(p.X * m.M11 + p.Y * m.M12 + p.Z * m.M13 + m.M14, p.X * m.M21 + p.Y * m.M22 + p.Z * m.M23 + m.M24, p.X * m.M31 + p.Y * m.M32 + p.Z * m.M33 + m.M34);
- }
-
- public static Matrix3D operator +(Matrix3D m, float n)
- {
- return new Matrix3D(m.M11 + n, m.M12 + n, m.M13 + n, m.M14 + n, m.M21 + n, m.M22 + n, m.M23 + n, m.M24 + n, m.M31 + n, m.M32 + n, m.M33 + n, m.M34 + n, m.M41 + n, m.M42 + n, m.M43 + n, m.M44 + n);
- }
-
- public static Matrix3D operator -(Matrix3D m, float n)
- {
- return new Matrix3D(m.M11 - n, m.M12 - n, m.M13 - n, m.M14 - n, m.M21 - n, m.M22 - n, m.M23 - n, m.M24 - n, m.M31 - n, m.M32 - n, m.M33 - n, m.M34 - n, m.M41 - n, m.M42 - n, m.M43 - n, m.M44 - n);
- }
-
- public static Matrix3D operator *(Matrix3D m, float n)
- {
- return new Matrix3D(m.M11 * n, m.M12 * n, m.M13 * n, m.M14 * n, m.M21 * n, m.M22 * n, m.M23 * n, m.M24 * n, m.M31 * n, m.M32 * n, m.M33 * n, m.M34 * n, m.M41 * n, m.M42 * n, m.M43 * n, m.M44 * n);
- }
-
- public static Matrix3D operator /(Matrix3D m, float n)
- {
- return new Matrix3D(m.M11 / n, m.M12 / n, m.M13 / n, m.M14 / n, m.M21 / n, m.M22 / n, m.M23 / n, m.M24 / n, m.M31 / n, m.M32 / n, m.M33 / n, m.M34 / n, m.M41 / n, m.M42 / n, m.M43 / n, m.M44 / n);
- }
-
- public float M11;
-
- public float M12;
-
- public float M13;
-
- public float M14;
-
- public float M21;
-
- public float M22;
-
- public float M23;
-
- public float M24;
-
- public float M31;
-
- public float M32;
-
- public float M33;
-
- public float M34;
-
- public float M41;
-
- public float M42;
-
- public float M43;
-
- public float M44;
- }
-}
diff --git a/PCK-Studio/Classes/Models/ModelView.Designer.cs b/PCK-Studio/Classes/Models/ModelView.Designer.cs
deleted file mode 100644
index 25d398b1..00000000
--- a/PCK-Studio/Classes/Models/ModelView.Designer.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-
-namespace PckStudio.Models
-{
- partial class MinecraftModelView
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
-
-
-
- protected override void Dispose(bool disposing)
- {
- if (disposing && this.components != null)
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Component Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
-
- private void InitializeComponent()
- {
- components = new System.ComponentModel.Container();
- }
-
-
- private PckStudio.Models.BackgroundTypes backgroundType;
-
- private System.Drawing.Brush backgroundBrush = new System.Drawing.SolidBrush(System.Drawing.Color.SkyBlue);
-
- private System.ComponentModel.BackgroundWorker downloader = new System.ComponentModel.BackgroundWorker();
-
- private System.Drawing.Point mouseLastLocation;
-
- private PckStudio.Models.Object3D rotatingObject3D;
-
- private System.Drawing.Color backgroundColor = System.Drawing.Color.Transparent;
-
- private System.Drawing.Color backgroundGradientColor1 = System.Drawing.SystemColors.ControlDarkDark;
-
- private System.Drawing.Color backgroundGradientColor2 = System.Drawing.SystemColors.ControlLightLight;
-
- private static System.Drawing.Color textShadowColor = System.Drawing.Color.FromArgb(0x3F, 0x3F, 0x3F);
-
- private System.Drawing.Image backgroundTexture;
-
- private System.Drawing.Image usernameImage;
-
- internal PckStudio.Models.Matrix3D GlobalTransformation = PckStudio.Models.Matrix3D.Identity;
-
- private System.Collections.Generic.List texelList = new System.Collections.Generic.List();
-
- private PckStudio.Models.TexelComparer texelComparer = new PckStudio.Models.TexelComparer();
-
- private System.Collections.Generic.List object3DList = new System.Collections.Generic.List();
-
- private System.Collections.Generic.List dynamicObject3DtList = new System.Collections.Generic.List();
- #endregion
- }
-}
diff --git a/PCK-Studio/Classes/Models/ModelView.cs b/PCK-Studio/Classes/Models/ModelView.cs
deleted file mode 100644
index 070e51ec..00000000
--- a/PCK-Studio/Classes/Models/ModelView.cs
+++ /dev/null
@@ -1,431 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
-using System.Drawing.Text;
-using System.IO;
-using System.Net;
-using System.Threading;
-using System.Windows.Forms;
-
-namespace PckStudio.Models
-{
- public partial class MinecraftModelView : Control
- {
- private const int IsometricFOV = 46;
-
- internal float cameraZ = 31.4285717f;
-
- private int Fov = 70;
-
- private float scale = 1f;
-
- internal float RotationX;
-
- internal float RotationY;
-
- private bool perspective = true;
-
- private float PiBy180 = 0.0174532924f;
-
- protected override void OnBackColorChanged(EventArgs e)
- {
- base.OnBackColorChanged(e);
- backgroundColor = BackColor;
- UpdateBackgroundBrush();
- Invalidate();
- }
-
- [Browsable(true)]
- [Category("Appearance")]
- public System.Drawing.Color BackGradientColor1
- {
- get
- {
- return backgroundGradientColor1;
- }
- set
- {
- backgroundGradientColor1 = value;
- UpdateBackgroundBrush();
- Invalidate();
- }
- }
-
- [Browsable(true)]
- [Category("Appearance")]
- public System.Drawing.Color BackGradientColor2
- {
- get
- {
- return backgroundGradientColor2;
- }
- set
- {
- backgroundGradientColor2 = value;
- UpdateBackgroundBrush();
- Invalidate();
- }
- }
-
- [Browsable(true)]
- [Category("Appearance")]
- public new System.Drawing.Image BackgroundImage
- {
- get
- {
- return backgroundTexture;
- }
- set
- {
- backgroundTexture = value;
- UpdateBackgroundBrush();
- Invalidate();
- }
- }
-
- [Browsable(true)]
- [Category("Appearance")]
- public BackgroundTypes BackgroundType
- {
- get
- {
- return backgroundType;
- }
- set
- {
- backgroundType = value;
- UpdateBackgroundBrush();
- Invalidate();
- }
- }
-
- [Browsable(true)]
- [Category("View")]
- public ProjectionTypes Projection
- {
- get
- {
- return perspective ? ProjectionTypes.Perspective : ProjectionTypes.Isometric;
- }
- set
- {
- perspective = value == ProjectionTypes.Perspective;
- SetupProjection();
- foreach (Object3D object3D in object3DList)
- {
- object3D.Update();
- }
- Invalidate();
- }
- }
-
- [Browsable(true)]
- [Category("View")]
- public int FOV
- {
- get
- {
- return Fov;
- }
- set
- {
- Fov = value;
- SetupProjection();
- foreach (Object3D object3D in object3DList)
- {
- object3D.Update();
- }
- Invalidate();
- }
- }
-
- [Browsable(true)]
- [Category("View")]
- public int DegreesX
- {
- get
- {
- return (int)RotationX;
- }
- set
- {
- RotationX = value;
- Matrix3D globalTransformation = Matrix3D.CreateRotationX(RotationX * PiBy180) * Matrix3D.CreateRotationY(RotationY * PiBy180);
- foreach (Object3D object3D in object3DList)
- {
- object3D.GlobalTransformation = globalTransformation;
- }
- Invalidate();
- }
- }
-
- [Browsable(true)]
- [Category("View")]
- public int DegreesY
- {
- get
- {
- return (int)RotationY;
- }
- set
- {
- RotationY = value;
- Matrix3D globalTransformation = Matrix3D.CreateRotationX(RotationX * PiBy180) * Matrix3D.CreateRotationY(RotationY * PiBy180);
- foreach (Object3D object3D in object3DList)
- {
- object3D.GlobalTransformation = globalTransformation;
- }
- Invalidate();
- }
- }
-
- public ModelBase Model
- {
- set
- {
- Clear();
- value.AddToModelView(this);
- Matrix3D globalTransformation = Matrix3D.CreateRotationX(RotationX * 3.14159274f / 180f) * Matrix3D.CreateRotationY(RotationY * 3.14159274f / 180f);
- foreach (Object3D object3D in object3DList)
- {
- object3D.GlobalTransformation = globalTransformation;
- }
- Invalidate();
- }
- }
-
- private void Clear()
- {
- texelList.Clear();
- object3DList.Clear();
- dynamicObject3DtList.Clear();
- rotatingObject3D = null;
- }
-
- protected override void OnPaintBackground(PaintEventArgs pevent)
- {
- base.OnPaintBackground(pevent);
- System.Drawing.Graphics graphics = pevent.Graphics;
- graphics.CompositingQuality = CompositingQuality.HighSpeed;
- graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
- graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
- graphics.SmoothingMode = SmoothingMode.HighSpeed;
- graphics.CompositingMode = CompositingMode.SourceCopy;
- graphics.FillRectangle(backgroundBrush, ClientRectangle);
- graphics.CompositingMode = CompositingMode.SourceOver;
- }
-
- protected override void OnPaint(PaintEventArgs pe)
- {
- texelList.Sort(texelComparer);
- System.Drawing.Graphics graphics = pe.Graphics;
- graphics.TranslateTransform(Width / 2, Height / 2);
- graphics.ScaleTransform(scale, -scale);
- graphics.CompositingQuality = CompositingQuality.HighSpeed;
- graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
- graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
- graphics.SmoothingMode = SmoothingMode.HighSpeed;
- graphics.CompositingMode = CompositingMode.SourceCopy;
- for (int i = 0; i < texelList.Count; i++)
- {
- texelList[i].Draw(graphics);
- }
- }
-
- public System.Drawing.Image RenderToImage(System.Drawing.Size size, System.Drawing.RectangleF crop)
- {
- if (size.Width / size.Height != crop.Width / crop.Height)
- {
- throw new ArgumentException("Aspect ratio is ambiguous");
- }
- System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(size.Width, size.Height);
- using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap))
- {
- System.Drawing.Size size2 = new System.Drawing.Size((int)(size.Width / crop.Width), (int)(size.Height / crop.Height));
- texelList.Sort(texelComparer);
- graphics.TranslateTransform(-crop.Left * size2.Width, -crop.Top * size2.Height);
- graphics.TranslateTransform(size2.Width / 2, size2.Height / 2);
- float num = Math.Min(size2.Width, size2.Height) * 0.01f / (float)Math.Tan((perspective ? Fov : IsometricFOV) * 3.1415926535897931 / 360.0);
- graphics.ScaleTransform(num, -num);
- graphics.CompositingQuality = CompositingQuality.HighSpeed;
- graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
- graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
- graphics.SmoothingMode = SmoothingMode.HighSpeed;
- graphics.Clear(System.Drawing.Color.Transparent);
- for (int i = 0; i < texelList.Count; i++)
- {
- texelList[i].Draw(graphics);
- }
- }
- return bitmap;
- }
-
- private System.Drawing.Image RenderVersionText()
- {
- System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(0x154, 0x12);
- Version version = new Version(Application.ProductVersion);
- string s = string.Format("{0} {1}.{2}{3}", Application.ProductName, version.Major, version.Minor, (version.Build != 0) ? ("." + version.Build) : "");
- using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap))
- {
- using (System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(0x7F, System.Drawing.Color.Gray)))
- {
- graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
- graphics.DrawString(s, Font, brush, 1f, 1f);
- graphics.DrawString(s, Font, System.Drawing.Brushes.White, 0f, 0f);
- }
- }
- return bitmap;
- }
-
- private void UpdateBackgroundBrush()
- {
- backgroundBrush = ((backgroundType == BackgroundTypes.Texture) ? new System.Drawing.TextureBrush(backgroundTexture) : ((backgroundType == BackgroundTypes.Gradient) ? new System.Drawing.Drawing2D.LinearGradientBrush(new System.Drawing.Point(0, 0), new System.Drawing.Point(0, System.Math.Max(1, base.Height)), backgroundGradientColor1, backgroundGradientColor2) : new System.Drawing.SolidBrush(backgroundColor)));
- }
-
- public System.Drawing.Brush GetBackgroundBrush(System.Drawing.Size size)
- {
- if (backgroundType == BackgroundTypes.Texture)
- {
- return new System.Drawing.TextureBrush(backgroundTexture);
- }
- if (backgroundType != BackgroundTypes.Gradient)
- {
- return new System.Drawing.SolidBrush(backgroundColor);
- }
- return new LinearGradientBrush(new System.Drawing.Point(0, 0), new System.Drawing.Point(0, Math.Max(1, size.Height)), backgroundGradientColor1, backgroundGradientColor2);
- }
-
- private void SetupProjection()
- {
- cameraZ = 2400f / Fov;
- scale = Math.Min(Width, Height) * 0.01f / (float)Math.Tan((perspective ? Fov : IsometricFOV) * Math.PI / 360.0);
- }
-
- protected override void OnResize(EventArgs e)
- {
- SetupProjection();
- UpdateBackgroundBrush();
- base.OnResize(e);
- }
-
- internal void RemoveTexelsOf(TexturePlane texturePlane)
- {
- for (int i = 0; i < texelList.Count; i++)
- {
- if (texelList[i].TexturePlane == texturePlane)
- {
- texelList.RemoveAt(i);
- i--;
- }
- }
- }
-
- internal void AddTexel(Texel texel)
- {
- texelList.Add(texel);
- }
-
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- System.Drawing.PointF location = new System.Drawing.PointF((e.X - Width * 0.5f) / scale, -(e.Y - Height * 0.5f) / scale);
- rotatingObject3D = null;
- Object3D item = null;
- float num = -1000f;
- foreach (Object3D object3D in object3DList)
- {
- float num2 = object3D.HitTest(location);
- if (num2 > num)
- {
- num = num2;
- item = object3D;
- }
- }
- if (num > -1000f && dynamicObject3DtList.Contains(item))
- {
- rotatingObject3D = item;
- }
- mouseLastLocation = e.Location;
- Invalidate();
- }
-
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- rotatingObject3D = null;
- }
-
- protected override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- if (e.Button != MouseButtons.Left)
- {
- return;
- }
- if (rotatingObject3D != null)
- {
- rotatingObject3D.RotateByMouse((e.X - mouseLastLocation.X) * 400f / Height, (e.Y - mouseLastLocation.Y) * 400f / Height);
- mouseLastLocation = e.Location;
- Invalidate();
- return;
- }
- RotationY += (e.X - mouseLastLocation.X) * 400f / Height;
- RotationX += (e.Y - mouseLastLocation.Y) * 400f / Height;
- mouseLastLocation = e.Location;
- Matrix3D globalTransformation = Matrix3D.CreateRotationX(RotationX * 3.14159274f / 180f) * Matrix3D.CreateRotationY(RotationY * 3.14159274f / 180f);
- foreach (Object3D object3D in object3DList)
- {
- object3D.GlobalTransformation = globalTransformation;
- }
- Invalidate();
- }
-
- public void AddStatic(Object3D object3D)
- {
- object3D.Viewport = this;
- object3DList.Add(object3D);
- foreach (Object3D object3D2 in object3DList)
- {
- object3D2.Update();
- }
- }
-
- public void AddDynamic(Object3D object3D)
- {
- AddStatic(object3D);
- dynamicObject3DtList.Add(object3D);
- }
-
- internal System.Drawing.PointF Point3DTo2D(Point3D point3D)
- {
- if (perspective)
- {
- return new System.Drawing.PointF(point3D.X * (-50f / (point3D.Z - cameraZ)), point3D.Y * (-50f / (point3D.Z - cameraZ)));
- }
- return new System.Drawing.PointF(point3D.X, point3D.Y);
- }
-
- internal float GetZOrder(Point3D point3D)
- {
- if (perspective)
- {
- return point3D.X * point3D.X + point3D.Y * point3D.Y + (cameraZ - point3D.Z) * (cameraZ - point3D.Z);
- }
- return -point3D.Z;
- }
-
- public MinecraftModelView()
- {
- SetStyle(ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
- InitializeComponent();
- texelComparer = new TexelComparer();
- }
-
- public MinecraftModelView(IContainer container) : this()
- {
- container.Add(this);
- }
- }
-}
diff --git a/PCK-Studio/Classes/Models/Object3D.cs b/PCK-Studio/Classes/Models/Object3D.cs
deleted file mode 100644
index f9aa9f6a..00000000
--- a/PCK-Studio/Classes/Models/Object3D.cs
+++ /dev/null
@@ -1,461 +0,0 @@
-using System;
-using System.Drawing;
-
-namespace PckStudio.Models
-{
- public abstract class Object3D
- {
- public abstract Image Image { set; }
-
- public float Angle1
- {
- get
- {
- return angle1;
- }
- set
- {
- angle1 = value;
- OnUpdateRotation();
- }
- }
-
- public float Angle2
- {
- get
- {
- return angle2;
- }
- set
- {
- angle2 = value;
- OnUpdateRotation();
- }
- }
-
- public float MinAngle1
- {
- get
- {
- return minAngle1;
- }
- set
- {
- minAngle1 = value;
- }
- }
-
- public float MinAngle2
- {
- get
- {
- return minAngle2;
- }
- set
- {
- minAngle2 = value;
- }
- }
-
- public float MaxAngle1
- {
- get
- {
- return maxAngle1;
- }
- set
- {
- maxAngle1 = value;
- }
- }
-
- public float MaxAngle2
- {
- get
- {
- return maxAngle2;
- }
- set
- {
- maxAngle2 = value;
- }
- }
-
- public float AngleRange1
- {
- get
- {
- return maxAngle1 - minAngle1;
- }
- set
- {
- minAngle1 = angle1 - value / 2f;
- maxAngle1 = angle1 + value / 2f;
- }
- }
-
- public float AngleRange2
- {
- get
- {
- return maxAngle2 - minAngle2;
- }
- set
- {
- minAngle2 = angle2 - value / 2f;
- maxAngle2 = angle2 + value / 2f;
- }
- }
-
- public float MinDegrees1
- {
- get
- {
- return minAngle1 / PIby180;
- }
- set
- {
- minAngle1 = value * PIby180;
- }
- }
-
- public float MinDegrees2
- {
- get
- {
- return minAngle2 / PIby180;
- }
- set
- {
- minAngle2 = value * PIby180;
- }
- }
-
- public float MaxDegrees1
- {
- get
- {
- return maxAngle1 / PIby180;
- }
- set
- {
- maxAngle1 = value * PIby180;
- }
- }
-
- public float MaxDegrees2
- {
- get
- {
- return maxAngle2 / PIby180;
- }
- set
- {
- maxAngle2 = value * PIby180;
- }
- }
-
- public float DegreesRange1
- {
- get
- {
- return AngleRange1 / PIby180;
- }
- set
- {
- AngleRange1 = value * PIby180;
- }
- }
-
- public float DegreesRange2
- {
- get
- {
- return AngleRange2 / PIby180;
- }
- set
- {
- AngleRange2 = value * PIby180;
- }
- }
-
- public float Scale
- {
- get
- {
- return scaleTransformation.M11;
- }
- set
- {
- scaleTransformation = Matrix3D.CreateScale(value);
- UpdateRotation();
- }
- }
-
- public RotationOrders RotationOrder
- {
- get
- {
- return order;
- }
- set
- {
- order = value;
- switch (order)
- {
- case RotationOrders.XY:
- Rotate = new RotateMethod(RotateXY);
- OnUpdateRotation = UpdateRotationXY;
- return;
- case RotationOrders.YX:
- Rotate = new RotateMethod(RotateYX);
- OnUpdateRotation = UpdateRotationYX;
- return;
- case RotationOrders.XZ:
- Rotate = new RotateMethod(RotateXZ);
- OnUpdateRotation = UpdateRotationXZ;
- return;
- case RotationOrders.ZX:
- Rotate = new RotateMethod(RotateZX);
- OnUpdateRotation = UpdateRotationZX;
- return;
- case RotationOrders.YZ:
- Rotate = new RotateMethod(RotateYZ);
- OnUpdateRotation = UpdateRotationYZ;
- return;
- case RotationOrders.ZY:
- Rotate = new RotateMethod(RotateZY);
- OnUpdateRotation = UpdateRotationZY;
- return;
- default:
- return;
- }
- }
- }
-
- internal virtual MinecraftModelView Viewport
- {
- set
- {
- viewport = value;
- }
- }
-
- public Point3D Origin
- {
- get
- {
- return new Point3D(-originTranslation.M14, -originTranslation.M24, -originTranslation.M34);
- }
- set
- {
- originTranslation = Matrix3D.CreateTranslation(-value.X, -value.Y, -value.Z);
- UpdateRotation();
- }
- }
-
- public Point3D Position
- {
- get
- {
- return new Point3D(positionTranslation.M14, positionTranslation.M24, positionTranslation.M34);
- }
- set
- {
- positionTranslation = Matrix3D.CreateTranslation(value);
- UpdateRotation();
- Update();
- }
- }
-
- internal abstract void Update();
-
- public Matrix3D GlobalTransformation
- {
- get
- {
- return globalTransformation;
- }
- set
- {
- globalTransformation = value;
- Update();
- }
- }
-
- public Matrix3D LocalTransformation
- {
- get
- {
- return localTransformation;
- }
- set
- {
- localTransformation = value;
- Update();
- }
- }
-
- public void SetRotation(float angle1, float angle2)
- {
- this.angle1 = angle1;
- this.angle2 = angle2;
- OnUpdateRotation();
- }
-
- public void RotateByMouse(float deltaX, float deltaY)
- {
- if (Rotate != null)
- {
- Rotate(deltaX, deltaY);
- Update();
- }
- }
-
- private void CorrectAngles()
- {
- if (angle1 > maxAngle1)
- {
- angle1 = maxAngle1;
- }
- else if (angle1 < minAngle1)
- {
- angle1 = minAngle1;
- }
- if (angle2 > maxAngle2)
- {
- angle2 = maxAngle2;
- return;
- }
- if (angle2 < minAngle2)
- {
- angle2 = minAngle2;
- }
- }
-
- public abstract float HitTest(PointF location);
-
- private void RotateXY(float delta1, float delta2)
- {
- angle1 += delta1 * PIby180;
- angle2 += delta2 * PIby180 * (float)Math.Cos((double)(viewport.RotationY * PIby180));
- UpdateRotationXY();
- }
-
- private void RotateYX(float delta1, float delta2)
- {
- angle1 += delta1 * PIby180;
- angle2 += delta2 * PIby180 * (float)Math.Cos(viewport.RotationY * 3.1415926535897931 / 180.0);
- UpdateRotationYX();
- }
-
- private void RotateXZ(float delta1, float delta2)
- {
- angle1 += delta1 * PIby180 * (float)Math.Cos((double)(viewport.RotationY * PIby180)) + delta2 * PIby180 * (float)Math.Sin((double)(viewport.RotationY * PIby180));
- angle2 += delta2 * PIby180 * (float)Math.Cos((double)(viewport.RotationY * PIby180)) - delta1 * PIby180 * (float)Math.Sin((double)(viewport.RotationY * PIby180));
- UpdateRotationXZ();
- }
-
- private void RotateZX(float delta1, float delta2)
- {
- angle1 += delta1 * PIby180 * (float)Math.Cos((double)(viewport.RotationY * PIby180)) + delta2 * PIby180 * (float)Math.Sin((double)(viewport.RotationY * PIby180));
- angle2 += delta2 * PIby180 * (float)Math.Cos((double)(viewport.RotationY * PIby180)) - delta1 * PIby180 * (float)Math.Sin((double)(viewport.RotationY * PIby180));
- UpdateRotationZX();
- }
-
- private void RotateZY(float delta1, float delta2)
- {
- angle1 -= delta2 * PIby180;
- angle2 += delta1 * PIby180;
- UpdateRotationZY();
- }
-
- private void RotateYZ(float delta1, float delta2)
- {
- angle1 += delta1 * PIby180;
- angle2 += delta2 * PIby180 * (float)Math.Sin((double)(viewport.RotationY * PIby180));
- UpdateRotationYZ();
- }
-
- private void UpdateRotationXY()
- {
- CorrectAngles();
- localRotation = Matrix3D.CreateRotationY(angle1) * Matrix3D.CreateRotationX(angle2);
- UpdateRotation();
- }
-
- private void UpdateRotationYX()
- {
- CorrectAngles();
- localRotation = Matrix3D.CreateRotationX(angle2) * Matrix3D.CreateRotationY(angle1);
- UpdateRotation();
- }
-
- private void UpdateRotationXZ()
- {
- CorrectAngles();
- localRotation = Matrix3D.CreateRotationZ(angle1) * Matrix3D.CreateRotationX(angle2);
- UpdateRotation();
- }
-
- private void UpdateRotationZX()
- {
- CorrectAngles();
- localRotation = Matrix3D.CreateRotationX(angle2) * Matrix3D.CreateRotationZ(angle1);
- UpdateRotation();
- }
-
- private void UpdateRotationZY()
- {
- CorrectAngles();
- localRotation = Matrix3D.CreateRotationY(angle2) * Matrix3D.CreateRotationZ(angle1);
- UpdateRotation();
- }
-
- private void UpdateRotationYZ()
- {
- CorrectAngles();
- localRotation = Matrix3D.CreateRotationZ(angle2) * Matrix3D.CreateRotationY(angle1);
- UpdateRotation();
- }
-
- private void UpdateRotation()
- {
- localTransformation = positionTranslation * localRotation * originTranslation * scaleTransformation;
- }
-
- public const float PIby180 = 0.0174532924f;
-
- protected Matrix3D originTranslation = Matrix3D.Identity;
-
- protected Matrix3D positionTranslation = Matrix3D.Identity;
-
- protected Matrix3D scaleTransformation = Matrix3D.Identity;
-
- protected Matrix3D localRotation = Matrix3D.Identity;
-
- protected Matrix3D localTransformation = Matrix3D.Identity;
-
- protected Matrix3D globalTransformation = Matrix3D.Identity;
-
- private float angle1;
-
- private float angle2;
-
- private float maxAngle1 = (float)Math.PI;
- private float minAngle1 = (float)-Math.PI;
-
- private float maxAngle2 = (float)Math.PI;
- private float minAngle2 = (float)-Math.PI;
-
- private RotationOrders order;
-
- protected MinecraftModelView viewport;
-
- private RotateMethod Rotate;
-
- private Action OnUpdateRotation;
-
- private delegate void RotateMethod(float deltaX, float deltaY);
- }
-}
diff --git a/PCK-Studio/Classes/Models/Object3DGroup.cs b/PCK-Studio/Classes/Models/Object3DGroup.cs
deleted file mode 100644
index fc3cd524..00000000
--- a/PCK-Studio/Classes/Models/Object3DGroup.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace PckStudio.Models
-{
- public class Object3DGroup : Object3D
- {
- internal override MinecraftModelView Viewport
- {
- set
- {
- base.Viewport = value;
- foreach (Object3D object3D in objects)
- {
- object3D.Viewport = value;
- }
- }
- }
-
- public override System.Drawing.Image Image
- {
- set
- {
- foreach (Object3D object3D in objects)
- {
- object3D.Image = value;
- }
- }
- }
-
- internal override void Update()
- {
- Matrix3D globalTransformation = this.globalTransformation * localTransformation;
- for (int i = 0; i < objects.Count; i++)
- {
- objects[i].GlobalTransformation = globalTransformation;
- }
- }
-
- public override float HitTest(System.Drawing.PointF location)
- {
- float num = -1000f;
- foreach (Object3D object3D in objects)
- {
- float num2 = object3D.HitTest(location);
- if (num2 > num)
- {
- num = num2;
- }
- }
- return num;
- }
-
- public void Add(Object3D object3D)
- {
- if (object3D == this)
- {
- throw new ArgumentException("Cannot add Object3D into itself.");
- }
- objects.Add(object3D);
- }
-
- private List objects = new List();
- }
-}
diff --git a/PCK-Studio/Classes/Models/Point3D.cs b/PCK-Studio/Classes/Models/Point3D.cs
deleted file mode 100644
index e69ebf0b..00000000
--- a/PCK-Studio/Classes/Models/Point3D.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-
-namespace PckStudio.Models
-{
- public struct Point3D
- {
- public float X;
- public float Y;
- public float Z;
-
- public Point3D(float x, float y, float z)
- {
- (X, Y, Z) = (x, y, z);
- }
-
- public static Point3D Zero => default(Point3D);
-
- public override string ToString()
- {
- return string.Format("({0};{1};{2})", X, Y, Z);
- }
-
- public static Point3D operator +(Point3D a, Point3D b) => new Point3D(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
-
- public static Point3D operator -(Point3D a, Point3D b) => new Point3D(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
-
- public static Point3D operator *(Point3D p, float s) => new Point3D(p.X * s, p.Y * s, p.Z * s);
-
- public static Point3D operator /(Point3D p, float s) => new Point3D(p.X / s, p.Y / s, p.Z / s);
- }
-}
diff --git a/PCK-Studio/Classes/Models/Positions.cs b/PCK-Studio/Classes/Models/Positions.cs
deleted file mode 100644
index 004ba901..00000000
--- a/PCK-Studio/Classes/Models/Positions.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-
-namespace PckStudio.Models
-{
- public enum Positions
- {
- Default,
- Outstretched,
- Walking,
- Running,
- Sitting,
- Zombie
- }
-}
diff --git a/PCK-Studio/Classes/Models/ProjectionTypes.cs b/PCK-Studio/Classes/Models/ProjectionTypes.cs
deleted file mode 100644
index 04d81550..00000000
--- a/PCK-Studio/Classes/Models/ProjectionTypes.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-
-namespace PckStudio.Models
-{
- public enum ProjectionTypes : byte
- {
- Perspective,
- Isometric
- }
-}
diff --git a/PCK-Studio/Classes/Models/RotationOrders.cs b/PCK-Studio/Classes/Models/RotationOrders.cs
deleted file mode 100644
index 0ca2c041..00000000
--- a/PCK-Studio/Classes/Models/RotationOrders.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-
-namespace PckStudio.Models
-{
- public enum RotationOrders : byte
- {
- XY,
- YX,
- XZ,
- ZX,
- YZ,
- ZY
- }
-}
diff --git a/PCK-Studio/Classes/Models/Texel.cs b/PCK-Studio/Classes/Models/Texel.cs
deleted file mode 100644
index 736bcb21..00000000
--- a/PCK-Studio/Classes/Models/Texel.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-
-namespace PckStudio.Models
-{
- internal struct Texel
- {
- internal Texel(TexturePlane texturePlane, int x, int y, System.Drawing.Color color)
- {
- TexturePlane = texturePlane;
- X = x;
- Y = y;
- this.color = color;
- brush = new System.Drawing.SolidBrush(color);
- pen = new System.Drawing.Pen(System.Drawing.Color.White, 0.01f);
- }
-
- internal double Z
- {
- get
- {
- return TexturePlane.ZOrder[X + 1, Y + 1];
- }
- }
-
- internal void Draw(System.Drawing.Graphics g)
- {
- System.Drawing.PointF[] points = new System.Drawing.PointF[]
- {
- TexturePlane.Points[X, Y],
- TexturePlane.Points[X + 1, Y],
- TexturePlane.Points[X + 1, Y + 1],
- TexturePlane.Points[X, Y + 1]
- };
- g.FillPolygon(brush, points);
- }
-
- internal TexturePlane TexturePlane;
-
- internal int X;
-
- internal int Y;
-
- private System.Drawing.Color color;
-
- private System.Drawing.Brush brush;
-
- private System.Drawing.Pen pen;
- }
-}
diff --git a/PCK-Studio/Classes/Models/TexelComparer.cs b/PCK-Studio/Classes/Models/TexelComparer.cs
deleted file mode 100644
index d7187760..00000000
--- a/PCK-Studio/Classes/Models/TexelComparer.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace PckStudio.Models
-{
- internal class TexelComparer : IComparer
- {
- public int Compare(Texel x, Texel y)
- {
- return -x.Z.CompareTo(y.Z);
- }
-
- public TexelComparer()
- {
- }
- }
-}
diff --git a/PCK-Studio/Classes/Models/TexturePlane.cs b/PCK-Studio/Classes/Models/TexturePlane.cs
deleted file mode 100644
index 0b7b7edf..00000000
--- a/PCK-Studio/Classes/Models/TexturePlane.cs
+++ /dev/null
@@ -1,189 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
-using System.Drawing;
-
-namespace PckStudio.Models
-{
- public class TexturePlane : Object3D
- {
- public override Image Image
- {
- set
- {
- Bitmap = (Bitmap)value;
- }
- }
-
- internal override MinecraftModelView Viewport
- {
- set
- {
- base.Viewport = value;
- if (bitmap != null && value != null)
- {
- UpdateBitmap();
- }
- }
- }
-
- internal override void Update()
- {
- if (Points == null || viewport == null)
- {
- return;
- }
- Matrix3D m = globalTransformation * localTransformation * originTranslation;
- for (int i = 0; i <= width; i++)
- {
- for (int j = 0; j <= height; j++)
- {
- Point3D point3D = m * new Point3D(i, j, 0f);
- Points[i, j] = viewport.Point3DTo2D(point3D);
- double num = (double)viewport.GetZOrder(point3D);
- ZOrder[i, j] += num;
- ZOrder[i + 1, j] += num;
- ZOrder[i, j + 1] += num;
- ZOrder[i + 1, j + 1] = num;
- }
- }
- }
-
- private Bitmap Bitmap
- {
- set
- {
- if (viewport == null)
- {
- bitmap = value;
- return;
- }
- texelList.Clear();
- if (bitmap != null)
- {
- viewport.RemoveTexelsOf(this);
- Points = null;
- }
- bitmap = value;
- if (bitmap != null)
- {
- UpdateBitmap();
- Update();
- }
- }
- }
-
- private void UpdateBitmap()
- {
- width = bitmap.Width;
- height = bitmap.Height;
- visibility = new bool[width, height];
- for (int i = 0; i < width; i++)
- {
- for (int j = 0; j < height; j++)
- {
- Color pixel = bitmap.GetPixel(i, j);
- int num = flipHorizontally ? (width - i - 1) : i;
- int num2 = flipVertically ? j : (height - j - 1);
- if (pixel.A == 0)
- {
- visibility[num, num2] = false;
- }
- else
- {
- visibility[num, num2] = true;
- Texel texel = new Texel(this, num, num2, pixel);
- viewport.AddTexel(texel);
- texelList.Add(texel);
- }
- }
- }
- Points = new PointF[width + 1, height + 1];
- ZOrder = new double[width + 2, height + 2];
- }
-
- public TexturePlane(Image bitmap, Rectangle srcRect, Point3D origin, Point3D normal, Effects effects)
- {
- Origin = origin;
- this.normal = normal;
- if (bitmap == null)
- {
- Bitmap = null;
- return;
- }
- Bitmap bitmap2 = new Bitmap(srcRect.Width, srcRect.Height);
- using (Graphics graphics = Graphics.FromImage(bitmap2))
- {
- graphics.DrawImage(bitmap, new Rectangle(0, 0, bitmap2.Width, bitmap2.Height), srcRect, GraphicsUnit.Pixel);
- }
- flipHorizontally = (byte)(effects & Effects.FlipHorizontally) == 1;
- flipVertically = (byte)(effects & Effects.FlipVertically) == 2;
- Bitmap = bitmap2;
- }
-
- public override float HitTest(PointF location)
- {
- if (Points == null)
- {
- return -1000f;
- }
- GraphicsPath graphicsPath = new GraphicsPath();
- graphicsPath.AddPolygon(new PointF[]
- {
- Points[0, 0],
- Points[Points.GetLength(0) - 1, 0],
- Points[Points.GetLength(0) - 1, Points.GetLength(1) - 1],
- Points[0, Points.GetLength(1) - 1]
- });
- Region region = new Region(graphicsPath);
- if (region.IsVisible(location))
- {
- for (int i = 0; i < Points.GetLength(0) - 1; i++)
- {
- for (int j = 0; j < Points.GetLength(1) - 1; j++)
- {
- if (visibility[i, j])
- {
- graphicsPath.Reset();
- graphicsPath.AddPolygon(new PointF[]
- {
- Points[i, j],
- Points[i + 1, j],
- Points[i + 1, j + 1],
- Points[i, j + 1]
- });
- if (graphicsPath.IsVisible(location))
- {
- return (globalTransformation * localTransformation * originTranslation * new Point3D(i, j, 0f)).Z;
- }
- }
- }
- }
- }
- return -1000f;
- }
-
- private List texelList = new List();
-
- internal PointF[,] Points;
-
- internal double[,] ZOrder;
-
- internal bool IsVisible = true;
-
- private bool[,] visibility;
-
- private Bitmap bitmap;
-
- private bool flipHorizontally;
-
- private bool flipVertically;
-
- private int width;
-
- private int height;
-
- private Point3D normal;
- }
-}
diff --git a/PCK-Studio/Classes/Utils/MouseRay.cs b/PCK-Studio/Classes/Utils/Ray.cs
similarity index 65%
rename from PCK-Studio/Classes/Utils/MouseRay.cs
rename to PCK-Studio/Classes/Utils/Ray.cs
index 3838d56d..8470a353 100644
--- a/PCK-Studio/Classes/Utils/MouseRay.cs
+++ b/PCK-Studio/Classes/Utils/Ray.cs
@@ -2,18 +2,16 @@
using System.Collections.Generic;
using System.Drawing;
using OpenTK;
-using PckStudio.ToolboxItems;
+using PckStudio.Rendering;
namespace PckStudio.Classes.Utils
{
-
- public class MouseRay
+ public class Ray
{
-
public Vector3 CurrentRay { get; set; } = new Vector3();
public Matrix4 ViewMatrix { get; set; }
- public Matrix4 projectionMatrix { get; set; }
+ public Matrix4 ProjectionMatrix { get; set; }
public Vector3 CamPos { get; set; }
@@ -21,9 +19,10 @@ namespace PckStudio.Classes.Utils
public Point Pos { get; set; }
+ // TODO: remove Renderer3D from Ray
public Renderer3D Renderer { get; set; }
- public struct ResultDistance
+ public struct RayResult
{
public float Distance { get; set; }
@@ -36,7 +35,7 @@ namespace PckStudio.Classes.Utils
public Is IsWhat { get; set; }
- public ResultDistance(float Distance, Is IsWhat)
+ public RayResult(float Distance, Is IsWhat)
{
this.Distance = Distance;
this.IsWhat = IsWhat;
@@ -87,7 +86,7 @@ namespace PckStudio.Classes.Utils
LegYIndex[0] = (-4 - CamPos.Y) / CurrentRay.Y;
LegYIndex[1] = (-16 - CamPos.Y) / CurrentRay.Y;
- var PointsDis = new List();
+ var PointsDis = new List();
Vector3 HeadPoint, BodyPoint, HeadXPoint, BodyXPoint, LegXPoint, HeadYPoint, BodyYPoint, LegYPoint;
@@ -96,7 +95,7 @@ namespace PckStudio.Classes.Utils
if (!(I > 1))
{
- HeadPoint = getPointOnRay(CurrentRay, HeadIndex[I]);
+ HeadPoint = GetPointOnRay(CurrentRay, HeadIndex[I]);
}
else
{
@@ -104,7 +103,7 @@ namespace PckStudio.Classes.Utils
}
if (!(I > 1))
{
- BodyPoint = getPointOnRay(CurrentRay, BodyIndex[I]);
+ BodyPoint = GetPointOnRay(CurrentRay, BodyIndex[I]);
}
else
{
@@ -113,16 +112,16 @@ namespace PckStudio.Classes.Utils
if (!(I > 1))
{
- HeadXPoint = getPointOnRay(CurrentRay, HeadXIndex[I]);
+ HeadXPoint = GetPointOnRay(CurrentRay, HeadXIndex[I]);
}
else
{
HeadXPoint = new Vector3(20f, 20f, 20f);
}
- BodyXPoint = getPointOnRay(CurrentRay, BodyXIndex[I]);
+ BodyXPoint = GetPointOnRay(CurrentRay, BodyXIndex[I]);
if (!(I > 2))
{
- LegXPoint = getPointOnRay(CurrentRay, LegXIndex[I]);
+ LegXPoint = GetPointOnRay(CurrentRay, LegXIndex[I]);
}
else
{
@@ -131,7 +130,7 @@ namespace PckStudio.Classes.Utils
if (!(I > 1))
{
- HeadYPoint = getPointOnRay(CurrentRay, HeadYIndex[I]);
+ HeadYPoint = GetPointOnRay(CurrentRay, HeadYIndex[I]);
}
else
{
@@ -139,7 +138,7 @@ namespace PckStudio.Classes.Utils
}
if (!(I > 1))
{
- BodyYPoint = getPointOnRay(CurrentRay, BodyYIndex[I]);
+ BodyYPoint = GetPointOnRay(CurrentRay, BodyYIndex[I]);
}
else
{
@@ -147,7 +146,7 @@ namespace PckStudio.Classes.Utils
}
if (!(I > 1))
{
- LegYPoint = getPointOnRay(CurrentRay, LegYIndex[I]);
+ LegYPoint = GetPointOnRay(CurrentRay, LegYIndex[I]);
}
else
{
@@ -156,95 +155,95 @@ namespace PckStudio.Classes.Utils
if (Renderer.ShowHead && HeadPoint.X < 4f && HeadPoint.X > -4 && HeadPoint.Y < 16f && HeadPoint.Y > 8f)
{
- PointsDis.Add(new ResultDistance(HeadIndex[I], ResultDistance.Is.Z));
+ PointsDis.Add(new RayResult(HeadIndex[I], RayResult.Is.Z));
}
if (Renderer.ShowBody && BodyPoint.X < 4f && BodyPoint.X > -4 && BodyPoint.Y < 8f && BodyPoint.Y > -4)
{
- PointsDis.Add(new ResultDistance(BodyIndex[I], ResultDistance.Is.Z));
+ PointsDis.Add(new RayResult(BodyIndex[I], RayResult.Is.Z));
}
if (Renderer.ShowRightArm && BodyPoint.Y > -4 && BodyPoint.Y < 8f)
{
if (Renderer.Model == Renderer3D.Models.Steve && BodyPoint.X > -8 && BodyPoint.X < -4 || Renderer.Model == Renderer3D.Models.Alex && BodyPoint.X > -7 && BodyPoint.X < -4)
{
- PointsDis.Add(new ResultDistance(BodyIndex[I], ResultDistance.Is.Z));
+ PointsDis.Add(new RayResult(BodyIndex[I], RayResult.Is.Z));
}
}
if (Renderer.ShowLeftArm && BodyPoint.Y < 8f && BodyPoint.Y > -4)
{
if (Renderer.Model == Renderer3D.Models.Steve && BodyPoint.X < 8f && BodyPoint.X > 4f || Renderer.Model == Renderer3D.Models.Alex && BodyPoint.X < 7f && BodyPoint.X > 4f)
{
- PointsDis.Add(new ResultDistance(BodyIndex[I], ResultDistance.Is.Z));
+ PointsDis.Add(new RayResult(BodyIndex[I], RayResult.Is.Z));
}
}
if (Renderer.ShowRightLeg && BodyPoint.X < 0f && BodyPoint.X > -4 && BodyPoint.Y < -4 && BodyPoint.Y > -16)
{
- PointsDis.Add(new ResultDistance(BodyIndex[I], ResultDistance.Is.Z));
+ PointsDis.Add(new RayResult(BodyIndex[I], RayResult.Is.Z));
}
if (Renderer.ShowLeftLeg && BodyPoint.X < 4f && BodyPoint.X > 0f && BodyPoint.Y < -4 && BodyPoint.Y > -16)
{
- PointsDis.Add(new ResultDistance(BodyIndex[I], ResultDistance.Is.Z));
+ PointsDis.Add(new RayResult(BodyIndex[I], RayResult.Is.Z));
}
if (Renderer.ShowHead && HeadXPoint.Z < 4f && HeadXPoint.Z > -4 && HeadXPoint.Y < 16f && HeadXPoint.Y > 8f)
{
- PointsDis.Add(new ResultDistance(HeadXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(HeadXIndex[I], RayResult.Is.X));
}
if (Renderer.ShowRightArm && (Convert.ToInt32(BodyXPoint.X) == -8 || Convert.ToInt32(BodyXPoint.X) == -7) && BodyXPoint.Z < 2f && BodyXPoint.Z > -2 && BodyXPoint.Y < 8f && BodyXPoint.Y > -4)
{
- PointsDis.Add(new ResultDistance(BodyXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(BodyXIndex[I], RayResult.Is.X));
}
if (Renderer.ShowLeftArm && (Convert.ToInt32(BodyXPoint.X) == 8 || Convert.ToInt32(BodyXPoint.X) == 7) && BodyXPoint.Z < 2f && BodyXPoint.Z > -2 && BodyXPoint.Y < 8f && BodyXPoint.Y > -4)
{
- PointsDis.Add(new ResultDistance(BodyXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(BodyXIndex[I], RayResult.Is.X));
}
if (Renderer.ShowRightArm ^ Renderer.ShowBody && Convert.ToInt32(BodyXPoint.X) == -4 && BodyXPoint.Z < 2f && BodyXPoint.Z > -2 && BodyXPoint.Y < 8f && BodyXPoint.Y > -4)
{
- PointsDis.Add(new ResultDistance(BodyXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(BodyXIndex[I], RayResult.Is.X));
}
if (Renderer.ShowLeftArm ^ Renderer.ShowBody && Convert.ToInt32(BodyXPoint.X) == 4 && BodyXPoint.Z < 2f && BodyXPoint.Z > -2 && BodyXPoint.Y < 8f && BodyXPoint.Y > -4)
{
- PointsDis.Add(new ResultDistance(BodyXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(BodyXIndex[I], RayResult.Is.X));
}
if (Renderer.ShowRightLeg && Convert.ToInt32(LegXPoint.X) == -4 && LegXPoint.Z < 2f && LegXPoint.Z > -2 && LegXPoint.Y < -4 && LegXPoint.Y > -16)
{
- PointsDis.Add(new ResultDistance(LegXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(LegXIndex[I], RayResult.Is.X));
}
if (Renderer.ShowLeftLeg && Convert.ToInt32(LegXPoint.X) == 4 && LegXPoint.Z < 2f && LegXPoint.Z > -2 && LegXPoint.Y < -4 && LegXPoint.Y > -16)
{
- PointsDis.Add(new ResultDistance(LegXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(LegXIndex[I], RayResult.Is.X));
}
if (Renderer.ShowRightLeg ^ Renderer.ShowLeftLeg && Convert.ToInt32(LegXPoint.X) == 0 && LegXPoint.Z < 2f && LegXPoint.Z > -2 && LegXPoint.Y < -4 && LegXPoint.Y > -16)
{
- PointsDis.Add(new ResultDistance(LegXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(LegXIndex[I], RayResult.Is.X));
}
if (Renderer.ShowHead && HeadYPoint.Z < 4f && HeadYPoint.Z > -4 && HeadYPoint.X < 4f && HeadYPoint.X > -4)
{
- PointsDis.Add(new ResultDistance(HeadYIndex[I], ResultDistance.Is.Y));
+ PointsDis.Add(new RayResult(HeadYIndex[I], RayResult.Is.Y));
}
if (Renderer.ShowBody && BodyYPoint.Z < 2f && BodyYPoint.Z > -2 && BodyYPoint.X < 4f && BodyYPoint.X > -4)
{
- PointsDis.Add(new ResultDistance(BodyYIndex[I], ResultDistance.Is.Y));
+ PointsDis.Add(new RayResult(BodyYIndex[I], RayResult.Is.Y));
}
if (Renderer.ShowRightArm && BodyYPoint.Z < 2f && BodyYPoint.Z > -2)
{
if (Renderer.Model == Renderer3D.Models.Steve && BodyYPoint.X > -8 && BodyYPoint.X < -4 || Renderer.Model == Renderer3D.Models.Alex && BodyYPoint.X > -7 && BodyYPoint.X < -4)
{
- PointsDis.Add(new ResultDistance(BodyYIndex[I], ResultDistance.Is.Y));
+ PointsDis.Add(new RayResult(BodyYIndex[I], RayResult.Is.Y));
}
}
if (Renderer.ShowLeftArm && BodyYPoint.Z < 2f && BodyYPoint.Z > -2)
{
if (Renderer.Model == Renderer3D.Models.Steve && BodyYPoint.X < 8f && BodyYPoint.X > 4f || Renderer.Model == Renderer3D.Models.Alex && BodyYPoint.X < 7f && BodyYPoint.X > 4f)
{
- PointsDis.Add(new ResultDistance(BodyYIndex[I], ResultDistance.Is.Y));
+ PointsDis.Add(new RayResult(BodyYIndex[I], RayResult.Is.Y));
}
}
if (Renderer.ShowRightLeg && LegYPoint.Z < 2f && LegYPoint.Z > -2 && LegYPoint.X < 0f && LegYPoint.X > -4)
{
- PointsDis.Add(new ResultDistance(LegYIndex[I], ResultDistance.Is.Y));
+ PointsDis.Add(new RayResult(LegYIndex[I], RayResult.Is.Y));
}
if (Renderer.ShowLeftLeg && LegYPoint.Z < 2f && LegYPoint.Z > -2 && LegYPoint.X < 4f && LegYPoint.X > 0f)
{
- PointsDis.Add(new ResultDistance(LegYIndex[I], ResultDistance.Is.Y));
+ PointsDis.Add(new RayResult(LegYIndex[I], RayResult.Is.Y));
}
}
@@ -252,24 +251,24 @@ namespace PckStudio.Classes.Utils
if (PointsDis.Count == 0)
return default;
- var Smallest = new ResultDistance(1000f, ResultDistance.Is.X);
+ var Smallest = new RayResult(1000f, RayResult.Is.X);
- foreach (ResultDistance value in PointsDis)
+ foreach (RayResult value in PointsDis)
{
if (value.Distance < Smallest.Distance)
Smallest = value;
}
- var Result = getPointOnRay(CurrentRay, Smallest.Distance);
- if (Smallest.IsWhat == ResultDistance.Is.X)
+ var Result = GetPointOnRay(CurrentRay, Smallest.Distance);
+ if (Smallest.IsWhat == RayResult.Is.X)
{
Result.X = (int)Math.Round(Result.X);
}
- else if (Smallest.IsWhat == ResultDistance.Is.Y)
+ else if (Smallest.IsWhat == RayResult.Is.Y)
{
Result.Y = (int)Math.Round(Result.Y);
}
- else if (Smallest.IsWhat == ResultDistance.Is.Z)
+ else if (Smallest.IsWhat == RayResult.Is.Z)
{
Result.Z = (int)Math.Round(Result.Z);
}
@@ -329,110 +328,110 @@ namespace PckStudio.Classes.Utils
LegYIndex[0] = (float)((-3.64d - CamPos.Y) / CurrentRay.Y);
LegYIndex[1] = (float)((-16.36d - CamPos.Y) / CurrentRay.Y);
- var PointsDis = new List();
+ var PointsDis = new List();
Vector3 HeadPoint, BodyPoint, HeadXPoint, BodyXPoint, LArmXPoint, RArmXPoint, LLegXPoint, RLegXPoint, HeadYPoint, BodyYPoint, LegYPoint;
for (byte I = 0; I <= 1; I++)
{
- HeadPoint = getPointOnRay(CurrentRay, HeadIndex[I]);
- BodyPoint = getPointOnRay(CurrentRay, BodyIndex[I]);
+ HeadPoint = GetPointOnRay(CurrentRay, HeadIndex[I]);
+ BodyPoint = GetPointOnRay(CurrentRay, BodyIndex[I]);
- HeadXPoint = getPointOnRay(CurrentRay, HeadXIndex[I]);
- BodyXPoint = getPointOnRay(CurrentRay, BodyXIndex[I]);
- RArmXPoint = getPointOnRay(CurrentRay, RArmXIndex[I]);
- LArmXPoint = getPointOnRay(CurrentRay, LArmXIndex[I]);
- RLegXPoint = getPointOnRay(CurrentRay, RLegXIndex[I]);
- LLegXPoint = getPointOnRay(CurrentRay, LLegXIndex[I]);
+ HeadXPoint = GetPointOnRay(CurrentRay, HeadXIndex[I]);
+ BodyXPoint = GetPointOnRay(CurrentRay, BodyXIndex[I]);
+ RArmXPoint = GetPointOnRay(CurrentRay, RArmXIndex[I]);
+ LArmXPoint = GetPointOnRay(CurrentRay, LArmXIndex[I]);
+ RLegXPoint = GetPointOnRay(CurrentRay, RLegXIndex[I]);
+ LLegXPoint = GetPointOnRay(CurrentRay, LLegXIndex[I]);
- HeadYPoint = getPointOnRay(CurrentRay, HeadYIndex[I]);
- BodyYPoint = getPointOnRay(CurrentRay, BodyYIndex[I]);
- LegYPoint = getPointOnRay(CurrentRay, LegYIndex[I]);
+ HeadYPoint = GetPointOnRay(CurrentRay, HeadYIndex[I]);
+ BodyYPoint = GetPointOnRay(CurrentRay, BodyYIndex[I]);
+ LegYPoint = GetPointOnRay(CurrentRay, LegYIndex[I]);
- if (Renderer.Show2ndHead && HeadPoint.X < 4.24d && HeadPoint.X > -4.24d && HeadPoint.Y < 16.24d && HeadPoint.Y > 7.76d)
+ if (Renderer.ShowHeadOverlay && HeadPoint.X < 4.24d && HeadPoint.X > -4.24d && HeadPoint.Y < 16.24d && HeadPoint.Y > 7.76d)
{
- PointsDis.Add(new ResultDistance(HeadIndex[I], ResultDistance.Is.Z));
+ PointsDis.Add(new RayResult(HeadIndex[I], RayResult.Is.Z));
}
- if (Renderer.Show2ndBody && BodyPoint.X < 4.24d && BodyPoint.X > -4.24d && BodyPoint.Y < 8.36d && BodyPoint.Y > -4.36d)
+ if (Renderer.ShowBodyOverlay && BodyPoint.X < 4.24d && BodyPoint.X > -4.24d && BodyPoint.Y < 8.36d && BodyPoint.Y > -4.36d)
{
- PointsDis.Add(new ResultDistance(BodyIndex[I], ResultDistance.Is.Z));
+ PointsDis.Add(new RayResult(BodyIndex[I], RayResult.Is.Z));
}
- if (Renderer.Show2ndRightArm && BodyPoint.Y < 8.36d && BodyPoint.Y > -4.36d)
+ if (Renderer.ShowRightArmOverlay && BodyPoint.Y < 8.36d && BodyPoint.Y > -4.36d)
{
if (Renderer.Model == Renderer3D.Models.Steve && BodyPoint.X < -3.88d && BodyPoint.X > -8.12d || Renderer.Model == Renderer3D.Models.Alex && BodyPoint.X < -3.91d && BodyPoint.X > -7.09d)
{
- PointsDis.Add(new ResultDistance(BodyIndex[I], ResultDistance.Is.Z));
+ PointsDis.Add(new RayResult(BodyIndex[I], RayResult.Is.Z));
}
}
- if (Renderer.Show2ndLeftArm && BodyPoint.Y < 8.36d && BodyPoint.Y > -4.36d)
+ if (Renderer.ShowLeftArmOverlay && BodyPoint.Y < 8.36d && BodyPoint.Y > -4.36d)
{
if (Renderer.Model == Renderer3D.Models.Steve && BodyPoint.X < 8.12d && BodyPoint.X > 3.88d || Renderer.Model == Renderer3D.Models.Alex && BodyPoint.X < 7.09d && BodyPoint.X > 3.91d)
{
- PointsDis.Add(new ResultDistance(BodyIndex[I], ResultDistance.Is.Z));
+ PointsDis.Add(new RayResult(BodyIndex[I], RayResult.Is.Z));
}
}
- if (Renderer.Show2ndRightLeg && BodyPoint.X < 0.12d && BodyPoint.X > -4.12d && BodyPoint.Y < -3.64d && BodyPoint.Y > -16.36d)
+ if (Renderer.ShowRightLegOverlay && BodyPoint.X < 0.12d && BodyPoint.X > -4.12d && BodyPoint.Y < -3.64d && BodyPoint.Y > -16.36d)
{
- PointsDis.Add(new ResultDistance(BodyIndex[I], ResultDistance.Is.Z));
+ PointsDis.Add(new RayResult(BodyIndex[I], RayResult.Is.Z));
}
- if (Renderer.Show2ndLeftLeg && BodyPoint.X < 4.12d && BodyPoint.X > -0.12d && BodyPoint.Y < -3.64d && BodyPoint.Y > -16.36d)
+ if (Renderer.ShowLeftLegOverlay && BodyPoint.X < 4.12d && BodyPoint.X > -0.12d && BodyPoint.Y < -3.64d && BodyPoint.Y > -16.36d)
{
- PointsDis.Add(new ResultDistance(BodyIndex[I], ResultDistance.Is.Z));
+ PointsDis.Add(new RayResult(BodyIndex[I], RayResult.Is.Z));
}
- if (Renderer.Show2ndHead && HeadXPoint.Z < 4.24d && HeadXPoint.Z > -4.24d && HeadXPoint.Y < 16.24d && HeadXPoint.Y > 7.76d)
+ if (Renderer.ShowHeadOverlay && HeadXPoint.Z < 4.24d && HeadXPoint.Z > -4.24d && HeadXPoint.Y < 16.24d && HeadXPoint.Y > 7.76d)
{
- PointsDis.Add(new ResultDistance(HeadXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(HeadXIndex[I], RayResult.Is.X));
}
- if (Renderer.Show2ndBody && BodyXPoint.Z < 2.12d && BodyXPoint.Z > -2.12d && BodyXPoint.Y < 8.36d && BodyXPoint.Y > -4.36d)
+ if (Renderer.ShowBodyOverlay && BodyXPoint.Z < 2.12d && BodyXPoint.Z > -2.12d && BodyXPoint.Y < 8.36d && BodyXPoint.Y > -4.36d)
{
- PointsDis.Add(new ResultDistance(BodyXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(BodyXIndex[I], RayResult.Is.X));
}
- if (Renderer.Show2ndRightArm && RArmXPoint.Z < 2.12d && RArmXPoint.Z > -2.12d && RArmXPoint.Y < 8.36d && RArmXPoint.Y > -4.36d)
+ if (Renderer.ShowRightArmOverlay && RArmXPoint.Z < 2.12d && RArmXPoint.Z > -2.12d && RArmXPoint.Y < 8.36d && RArmXPoint.Y > -4.36d)
{
- PointsDis.Add(new ResultDistance(RArmXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(RArmXIndex[I], RayResult.Is.X));
}
- if (Renderer.Show2ndLeftArm && LArmXPoint.Z < 2.12d && LArmXPoint.Z > -2.12d && LArmXPoint.Y < 8.36d && LArmXPoint.Y > -4.36d)
+ if (Renderer.ShowLeftArmOverlay && LArmXPoint.Z < 2.12d && LArmXPoint.Z > -2.12d && LArmXPoint.Y < 8.36d && LArmXPoint.Y > -4.36d)
{
- PointsDis.Add(new ResultDistance(LArmXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(LArmXIndex[I], RayResult.Is.X));
}
- if (Renderer.Show2ndRightLeg && RLegXPoint.Z < 2.12d && RLegXPoint.Z > -2.12d && RLegXPoint.Y < -3.64d && RLegXPoint.Y > -16.36d)
+ if (Renderer.ShowRightLegOverlay && RLegXPoint.Z < 2.12d && RLegXPoint.Z > -2.12d && RLegXPoint.Y < -3.64d && RLegXPoint.Y > -16.36d)
{
- PointsDis.Add(new ResultDistance(RLegXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(RLegXIndex[I], RayResult.Is.X));
}
- if (Renderer.Show2ndLeftLeg && LLegXPoint.Z < 2.12d && LLegXPoint.Z > -2.12d && LLegXPoint.Y < -3.64d && LLegXPoint.Y > -16.36d)
+ if (Renderer.ShowLeftLegOverlay && LLegXPoint.Z < 2.12d && LLegXPoint.Z > -2.12d && LLegXPoint.Y < -3.64d && LLegXPoint.Y > -16.36d)
{
- PointsDis.Add(new ResultDistance(LLegXIndex[I], ResultDistance.Is.X));
+ PointsDis.Add(new RayResult(LLegXIndex[I], RayResult.Is.X));
}
- if (Renderer.Show2ndHead && HeadYPoint.Z < 4.24d && HeadYPoint.Z > -4.24d && HeadYPoint.X < 4.24d && HeadYPoint.X > -4.24d)
+ if (Renderer.ShowHeadOverlay && HeadYPoint.Z < 4.24d && HeadYPoint.Z > -4.24d && HeadYPoint.X < 4.24d && HeadYPoint.X > -4.24d)
{
- PointsDis.Add(new ResultDistance(HeadYIndex[I], ResultDistance.Is.Y));
+ PointsDis.Add(new RayResult(HeadYIndex[I], RayResult.Is.Y));
}
- if (Renderer.Show2ndBody && BodyYPoint.Z < 2.12d && BodyYPoint.Z > -2.12d && BodyYPoint.X < 4.24d && BodyYPoint.X > -4.24d)
+ if (Renderer.ShowBodyOverlay && BodyYPoint.Z < 2.12d && BodyYPoint.Z > -2.12d && BodyYPoint.X < 4.24d && BodyYPoint.X > -4.24d)
{
- PointsDis.Add(new ResultDistance(BodyYIndex[I], ResultDistance.Is.Y));
+ PointsDis.Add(new RayResult(BodyYIndex[I], RayResult.Is.Y));
}
- if (Renderer.Show2ndRightArm && BodyYPoint.Z < 2.12d && BodyYPoint.Z > -2.12d)
+ if (Renderer.ShowRightArmOverlay && BodyYPoint.Z < 2.12d && BodyYPoint.Z > -2.12d)
{
if (Renderer.Model == Renderer3D.Models.Steve && BodyYPoint.X < -3.88d && BodyYPoint.X > -8.12d || Renderer.Model == Renderer3D.Models.Alex && BodyYPoint.X < -3.91d && BodyYPoint.X > -7.09d)
{
- PointsDis.Add(new ResultDistance(BodyYIndex[I], ResultDistance.Is.Y));
+ PointsDis.Add(new RayResult(BodyYIndex[I], RayResult.Is.Y));
}
}
- if (Renderer.Show2ndLeftArm && BodyYPoint.Z < 2.12d && BodyYPoint.Z > -2.12d)
+ if (Renderer.ShowLeftArmOverlay && BodyYPoint.Z < 2.12d && BodyYPoint.Z > -2.12d)
{
if (Renderer.Model == Renderer3D.Models.Steve && BodyYPoint.X < 8.12d && BodyYPoint.X > 3.88d || Renderer.Model == Renderer3D.Models.Alex && BodyYPoint.X < 7.09d && BodyYPoint.X > 3.91d)
{
- PointsDis.Add(new ResultDistance(BodyYIndex[I], ResultDistance.Is.Y));
+ PointsDis.Add(new RayResult(BodyYIndex[I], RayResult.Is.Y));
}
}
- if (Renderer.Show2ndRightLeg && LegYPoint.Z < 2.12d && LegYPoint.Z > -2.12d && LegYPoint.X < 0.12d && LegYPoint.X > -4.12d)
+ if (Renderer.ShowRightLegOverlay && LegYPoint.Z < 2.12d && LegYPoint.Z > -2.12d && LegYPoint.X < 0.12d && LegYPoint.X > -4.12d)
{
- PointsDis.Add(new ResultDistance(LegYIndex[I], ResultDistance.Is.Y));
+ PointsDis.Add(new RayResult(LegYIndex[I], RayResult.Is.Y));
}
- if (Renderer.Show2ndLeftLeg && LegYPoint.Z < 2.12d && LegYPoint.Z > -2.12d && LegYPoint.X < 4.12d && LegYPoint.X > -0.12d)
+ if (Renderer.ShowLeftLegOverlay && LegYPoint.Z < 2.12d && LegYPoint.Z > -2.12d && LegYPoint.X < 4.12d && LegYPoint.X > -0.12d)
{
- PointsDis.Add(new ResultDistance(LegYIndex[I], ResultDistance.Is.Y));
+ PointsDis.Add(new RayResult(LegYIndex[I], RayResult.Is.Y));
}
}
@@ -440,15 +439,15 @@ namespace PckStudio.Classes.Utils
if (PointsDis.Count == 0)
return new Vector3(100f, 100f, 100f);
- var Smallest = new ResultDistance(1000f, ResultDistance.Is.Z);
+ var Smallest = new RayResult(1000f, RayResult.Is.Z);
- foreach (ResultDistance value in PointsDis)
+ foreach (RayResult value in PointsDis)
{
if (value.Distance < Smallest.Distance)
Smallest = value;
}
- var Result = getPointOnRay(CurrentRay, Smallest.Distance);
+ var Result = GetPointOnRay(CurrentRay, Smallest.Distance);
float[] ZIndex = new[] { 4.24f, 2.12f, (float)-4.24d, (float)-2.12d };
float[] XIndex;
@@ -464,7 +463,7 @@ namespace PckStudio.Classes.Utils
float AResult = 20f;
- if (Smallest.IsWhat == ResultDistance.Is.X)
+ if (Smallest.IsWhat == RayResult.Is.X)
{
foreach (float value in XIndex)
{
@@ -475,7 +474,7 @@ namespace PckStudio.Classes.Utils
}
Result.X = AResult;
}
- else if (Smallest.IsWhat == ResultDistance.Is.Y)
+ else if (Smallest.IsWhat == RayResult.Is.Y)
{
foreach (float value in YIndex)
{
@@ -486,7 +485,7 @@ namespace PckStudio.Classes.Utils
}
Result.Y = AResult;
}
- else if (Smallest.IsWhat == ResultDistance.Is.Z)
+ else if (Smallest.IsWhat == RayResult.Is.Z)
{
foreach (float value in ZIndex)
{
@@ -502,56 +501,55 @@ namespace PckStudio.Classes.Utils
}
}
-
- public MouseRay(ref Matrix4 View, ref Matrix4 Projection, Size TheSize, Vector3 Camera, Renderer3D TheRenderer)
+ public Ray(ref Matrix4 viewMatrix, ref Matrix4 projectionMatrix, Size size, Vector3 cameraPosition, Renderer3D renderer)
{
- projectionMatrix = Projection;
- ViewMatrix = View;
- Size = TheSize;
- CamPos = Camera;
- Renderer = TheRenderer;
+ ProjectionMatrix = projectionMatrix;
+ ViewMatrix = viewMatrix;
+ Size = size;
+ CamPos = cameraPosition;
+ Renderer = renderer;
}
private void Update(int X, int Y)
{
- CurrentRay = calculateMouseRay(X, Y);
+ CurrentRay = CalculateRay(X, Y);
}
- private Vector3 calculateMouseRay(int X, int Y)
+ private Vector3 CalculateRay(int x, int y)
{
- var normalizedCoords = getNormalisedDeviceCoordinates(X, Y);
+ var normalizedCoords = GetNormalisedDeviceCoordinates(x, y);
var clipCoords = new Vector4(normalizedCoords.X, normalizedCoords.Y, -1.0f, 1.0f);
- var eyeCoords = toEyeCoords(clipCoords);
- var worldRay = toWorldCoords(eyeCoords);
+ var eyeCoords = ToEyeCoords(clipCoords);
+ var worldRay = ToWorldCoords(eyeCoords);
return worldRay;
}
- private Vector4 toEyeCoords(Vector4 clipCoords)
+ private Vector4 ToEyeCoords(Vector4 clipCoords)
{
- var invertedProjection = Matrix4.Invert(projectionMatrix);
+ var invertedProjection = Matrix4.Invert(ProjectionMatrix);
var eyeCoords = Vector4.Transform(clipCoords, invertedProjection);
return new Vector4(eyeCoords.X, eyeCoords.Y, -1.0f, 0f);
}
- private Vector3 toWorldCoords(Vector4 eyeCoords)
+ private Vector3 ToWorldCoords(Vector4 eyeCoords)
{
var invertedView = Matrix4.Invert(ViewMatrix);
var rayWorld = Vector4.Transform(eyeCoords, invertedView);
- var TheMouseRay = new Vector3(rayWorld.X, rayWorld.Y, rayWorld.Z);
- TheMouseRay.Normalize();
- return TheMouseRay;
+ var ray = new Vector3(rayWorld);
+ ray.Normalize();
+ return ray;
}
- private Vector2 getNormalisedDeviceCoordinates(int x, int y)
+ private Vector2 GetNormalisedDeviceCoordinates(int x, int y)
{
float x2 = 2.0f * x / Size.Width - 1.0f;
float y2 = -(2.0f * y / Size.Height - 1.0f);
return new Vector2(x2, y2);
}
- private Vector3 getPointOnRay(Vector3 ray, float distance)
+ private Vector3 GetPointOnRay(Vector3 ray, float distance)
{
- var start = new Vector3(CamPos.X, CamPos.Y, CamPos.Z);
+ var start = new Vector3(CamPos);
var scaledRay = new Vector3(ray.X * distance, ray.Y * distance, ray.Z * distance);
return start + scaledRay;
}
diff --git a/PCK-Studio/Forms/Skins-And-Textures/SkinPreview.Designer.cs b/PCK-Studio/Forms/Skins-And-Textures/SkinPreview.Designer.cs
index b7b3f5ef..f1fa7241 100644
--- a/PCK-Studio/Forms/Skins-And-Textures/SkinPreview.Designer.cs
+++ b/PCK-Studio/Forms/Skins-And-Textures/SkinPreview.Designer.cs
@@ -31,24 +31,17 @@ namespace PckStudio.Forms
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SkinPreview));
- this.ModelView = new PckStudio.Models.MinecraftModelView(this.components);
+ this.ModelView = new PckStudio.Rendering.Renderer3D();
this.SuspendLayout();
//
// ModelView
//
this.ModelView.BackColor = System.Drawing.Color.DarkGray;
- this.ModelView.BackGradientColor1 = System.Drawing.SystemColors.ActiveCaptionText;
- this.ModelView.BackGradientColor2 = System.Drawing.SystemColors.ActiveCaptionText;
- this.ModelView.BackgroundType = PckStudio.Models.BackgroundTypes.Color;
- this.ModelView.DegreesX = 0;
- this.ModelView.DegreesY = 0;
this.ModelView.Dock = System.Windows.Forms.DockStyle.Fill;
this.ModelView.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ModelView.ForeColor = System.Drawing.Color.Black;
- this.ModelView.FOV = 90;
this.ModelView.Location = new System.Drawing.Point(0, 0);
this.ModelView.Name = "ModelView";
- this.ModelView.Projection = PckStudio.Models.ProjectionTypes.Perspective;
this.ModelView.Size = new System.Drawing.Size(418, 568);
this.ModelView.TabIndex = 1;
this.ModelView.Text = "PCK Model View";
@@ -70,6 +63,6 @@ namespace PckStudio.Forms
#endregion
- private PckStudio.Models.MinecraftModelView ModelView;
+ private PckStudio.Rendering.Renderer3D ModelView;
}
}
\ No newline at end of file
diff --git a/PCK-Studio/Forms/Skins-And-Textures/SkinPreview.cs b/PCK-Studio/Forms/Skins-And-Textures/SkinPreview.cs
index e3ce8ed0..185ccabf 100644
--- a/PCK-Studio/Forms/Skins-And-Textures/SkinPreview.cs
+++ b/PCK-Studio/Forms/Skins-And-Textures/SkinPreview.cs
@@ -1,34 +1,42 @@
using System;
using System.Drawing;
using System.Windows.Forms;
-using PckStudio.Classes.Models.DefaultModels;
using PckStudio.Internal;
-using PckStudio.Models;
+using PckStudio.Rendering;
namespace PckStudio.Forms
{
public partial class SkinPreview : Form
{
Image Texture;
- ModelBase Model;
- public SkinPreview(Image img, SkinANIM anim, ModelBase model = null)
+ public SkinPreview(Image texture, SkinANIM anim)
{
InitializeComponent();
- Texture = img;
+ Texture = texture;
+ ModelView.Model = anim.GetFlag(SkinAnimFlag.SLIM_MODEL) ? Renderer3D.Models.Alex : Renderer3D.Models.Steve;
- Model = model ?? new Steve64x32Model(Texture);
- if (img.Width == 64 && img.Height == 64)
- {
- Model = model ?? new Steve64x64Model(Texture, anim);
- }
+ ModelView.ShowHead = !anim.GetFlag(SkinAnimFlag.HEAD_DISABLED);
+ ModelView.ShowHeadOverlay = !anim.GetFlag(SkinAnimFlag.HEAD_OVERLAY_DISABLED);
+ ModelView.ShowBody = !anim.GetFlag(SkinAnimFlag.BODY_DISABLED);
+ ModelView.ShowBodyOverlay = !anim.GetFlag(SkinAnimFlag.BODY_OVERLAY_DISABLED);
+
+ ModelView.ShowLeftArm = !anim.GetFlag(SkinAnimFlag.LEFT_ARM_DISABLED);
+ ModelView.ShowLeftArmOverlay = !anim.GetFlag(SkinAnimFlag.LEFT_ARM_OVERLAY_DISABLED);
+ ModelView.ShowRightArm = !anim.GetFlag(SkinAnimFlag.RIGHT_ARM_DISABLED);
+ ModelView.ShowRightArmOverlay = !anim.GetFlag(SkinAnimFlag.RIGHT_ARM_OVERLAY_DISABLED);
+
+ ModelView.ShowLeftLeg = !anim.GetFlag(SkinAnimFlag.LEFT_LEG_DISABLED);
+ ModelView.ShowLeftLegOverlay = !anim.GetFlag(SkinAnimFlag.LEFT_LEG_OVERLAY_DISABLED);
+ ModelView.ShowRightLeg = !anim.GetFlag(SkinAnimFlag.RIGHT_LEG_DISABLED);
+ ModelView.ShowRightLegOverlay = !anim.GetFlag(SkinAnimFlag.RIGHT_LEG_OVERLAY_DISABLED);
}
private void SkinPreview_Load(object sender, EventArgs e) => RenderModel(Texture);
public void RenderModel(Image source)
{
- Model.AddToModelView(ModelView);
+ ModelView.Texture = source as Bitmap;
}
}
}
diff --git a/PCK-Studio/Forms/TestGL.Designer.cs b/PCK-Studio/Forms/TestGL.Designer.cs
index 408aea49..aa1d958d 100644
--- a/PCK-Studio/Forms/TestGL.Designer.cs
+++ b/PCK-Studio/Forms/TestGL.Designer.cs
@@ -28,28 +28,24 @@
///
private void InitializeComponent()
{
- this.renderer3D1 = new PckStudio.ToolboxItems.Renderer3D();
+ this.renderer3D1 = new PckStudio.Rendering.Renderer3D();
this.SuspendLayout();
//
// renderer3D1
//
this.renderer3D1.BackColor = System.Drawing.Color.Gray;
this.renderer3D1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.renderer3D1.InDesignMode = true;
this.renderer3D1.Location = new System.Drawing.Point(0, 0);
- this.renderer3D1.LookX = 0D;
- this.renderer3D1.LookY = 0D;
- this.renderer3D1.Model = PckStudio.ToolboxItems.Renderer3D.Models.Steve;
+ this.renderer3D1.Model = PckStudio.Rendering.Renderer3D.Models.Steve;
this.renderer3D1.Name = "renderer3D1";
- this.renderer3D1.Paintable = true;
this.renderer3D1.RotationX = 0;
this.renderer3D1.RotationY = 0;
- this.renderer3D1.Show2ndBody = true;
- this.renderer3D1.Show2ndHead = true;
- this.renderer3D1.Show2ndLeftArm = true;
- this.renderer3D1.Show2ndLeftLeg = true;
- this.renderer3D1.Show2ndRightArm = true;
- this.renderer3D1.Show2ndRightLeg = true;
+ this.renderer3D1.ShowBodyOverlay = true;
+ this.renderer3D1.ShowHeadOverlay = true;
+ this.renderer3D1.ShowLeftArmOverlay = true;
+ this.renderer3D1.ShowLeftLegOverlay = true;
+ this.renderer3D1.ShowRightArmOverlay = true;
+ this.renderer3D1.ShowRightLegOverlay = true;
this.renderer3D1.ShowBody = true;
this.renderer3D1.ShowHead = true;
this.renderer3D1.ShowLeftArm = true;
@@ -57,7 +53,7 @@
this.renderer3D1.ShowRightArm = true;
this.renderer3D1.ShowRightLeg = true;
this.renderer3D1.Size = new System.Drawing.Size(426, 428);
- this.renderer3D1.Skin = global::PckStudio.Properties.Resources.steve;
+ this.renderer3D1.Texture = global::PckStudio.Properties.Resources.classic_template;
this.renderer3D1.TabIndex = 8;
this.renderer3D1.Zoom = 1D;
//
@@ -76,6 +72,6 @@
#endregion
- private ToolboxItems.Renderer3D renderer3D1;
+ private PckStudio.Rendering.Renderer3D renderer3D1;
}
}
\ No newline at end of file
diff --git a/PCK-Studio/Forms/TestGL.cs b/PCK-Studio/Forms/TestGL.cs
index 00d1de5a..15d89aa6 100644
--- a/PCK-Studio/Forms/TestGL.cs
+++ b/PCK-Studio/Forms/TestGL.cs
@@ -1,5 +1,4 @@
-using PckStudio.ToolboxItems;
-using System;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -8,8 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
-using PckStudio.ToolboxItems;
-using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+using PckStudio.Properties;
namespace PckStudio.Forms
{
@@ -20,7 +18,7 @@ namespace PckStudio.Forms
InitializeComponent();
}
- internal Bitmap Skin = Properties.Resources.steve;
+ internal Bitmap Skin = Resources.classic_template;
internal void UpdateImage()
{
var Image = new Bitmap(Skin.Width, Skin.Height); // Create the skin preview bitmao
@@ -36,12 +34,11 @@ namespace PckStudio.Forms
Image.SetPixel(X, Y, Skin.GetPixel(X / 2, Y / 2));
}
// *************************************************************
- renderer3D1.Skin = Skin;
+ renderer3D1.Texture = Skin;
renderer3D1.Refresh(); // Render
}
private void TestGL_Load(object sender, EventArgs e)
{
- renderer3D1.InDesignMode = false;
UpdateImage(); // Load preview
}
}
diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs
index d5c880f5..14806253 100644
--- a/PCK-Studio/MainForm.cs
+++ b/PCK-Studio/MainForm.cs
@@ -2270,7 +2270,7 @@ namespace PckStudio
private void skinRenderer3DToolStripMenuItem_Click(object sender, EventArgs e)
{
- TestGL gl = new TestGL();
+ var gl = new TestGL();
gl.Show();
}
}
diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj
index 9ea88cee..8ad52caa 100644
--- a/PCK-Studio/PckStudio.csproj
+++ b/PCK-Studio/PckStudio.csproj
@@ -133,7 +133,7 @@
-
+
@@ -146,16 +146,21 @@
+
+ True
+ True
+ Resources.resx
+
Component
Component
-
+
UserControl
-
+
Renderer3D.cs
@@ -207,7 +212,6 @@
-
@@ -217,28 +221,6 @@
-
-
-
-
-
-
-
-
- Component
-
-
- ModelView.cs
-
-
-
-
-
-
-
-
-
-
@@ -629,11 +611,6 @@
SettingsSingleFileGenerator
Settings.Designer.cs
-
- True
- True
- Resources.resx
-
True
Settings.settings
diff --git a/PCK-Studio/ToolboxItems/Renderer3D.Designer.cs b/PCK-Studio/Rendering/Renderer3D.Designer.cs
similarity index 53%
rename from PCK-Studio/ToolboxItems/Renderer3D.Designer.cs
rename to PCK-Studio/Rendering/Renderer3D.Designer.cs
index 927bfda9..cabaf3c7 100644
--- a/PCK-Studio/ToolboxItems/Renderer3D.Designer.cs
+++ b/PCK-Studio/Rendering/Renderer3D.Designer.cs
@@ -3,12 +3,10 @@ using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
-namespace PckStudio.ToolboxItems
+namespace PckStudio.Rendering
{
- public partial class Renderer3D : UserControl
+ public partial class Renderer3D
{
-
- // UserControl overrides dispose to clean up the component list.
[DebuggerNonUserCode()]
protected override void Dispose(bool disposing)
{
@@ -35,50 +33,46 @@ namespace PckStudio.ToolboxItems
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
- GlControl = new OpenTK.GLControl();
- GlControl.Paint += new PaintEventHandler(GlControl_Paint);
- GlControl.MouseDown += new MouseEventHandler(GlControl_MouseDown);
- GlControl.MouseUp += new MouseEventHandler(GlControl_MouseUp);
timMove = new Timer(components);
timMove.Tick += new EventHandler(Move_Tick);
- timPaint = new Timer(components);
- timPaint.Tick += new EventHandler(Paint_Tick);
SuspendLayout();
//
- // GlControl
- //
- GlControl.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
-
- GlControl.BackColor = Color.Black;
- GlControl.Location = new Point(0, 0);
- GlControl.Name = "GlControl";
- GlControl.Size = new Size(150, 150);
- GlControl.TabIndex = 0;
- GlControl.VSync = true;
- //
// timMove
//
timMove.Enabled = true;
timMove.Interval = 20;
+#if DEBUG
//
- // timPaint
+ // debugLabel
//
- timPaint.Enabled = true;
- timPaint.Interval = 1;
+ debugLabel = new System.Windows.Forms.Label();
+ debugLabel.Enabled = true;
+ debugLabel.Visible = true;
+ debugLabel.AutoSize = true;
+ debugLabel.Location = new Point(0, 0);
+ debugLabel.BackColor = Color.Transparent;
+ Controls.Add(debugLabel);
+#endif
//
// Renderer3D
//
+ Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ BackColor = Color.Transparent;
+ Location = new Point(0, 0);
+ Size = new Size(150, 150);
+ TabIndex = 0;
+ VSync = true;
AutoScaleDimensions = new SizeF(6.0f, 13.0f);
AutoScaleMode = AutoScaleMode.Font;
- Controls.Add(GlControl);
Name = "Renderer3D";
- MouseWheel += new MouseEventHandler(Renderer3D_MouseWheel);
ResumeLayout(false);
}
- internal OpenTK.GLControl GlControl;
- internal Timer timMove;
- internal Timer timPaint;
+ private Timer timMove;
+#if DEBUG
+ private System.Windows.Forms.Label debugLabel;
+#endif
+
}
}
\ No newline at end of file
diff --git a/PCK-Studio/ToolboxItems/Renderer3D.cs b/PCK-Studio/Rendering/Renderer3D.cs
similarity index 86%
rename from PCK-Studio/ToolboxItems/Renderer3D.cs
rename to PCK-Studio/Rendering/Renderer3D.cs
index 07c16dde..cfbc92f3 100644
--- a/PCK-Studio/ToolboxItems/Renderer3D.cs
+++ b/PCK-Studio/Rendering/Renderer3D.cs
@@ -22,6 +22,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
https://github.com/KareemMAX/Minecraft-Skiner
+https://github.com/KareemMAX/Minecraft-Skiner/blob/master/src/Minecraft%20skiner/UserControls/Renderer3D.vb
*/
using System;
@@ -33,23 +34,25 @@ using System.Drawing.Imaging;
using System.Linq;
using System.Windows.Forms;
using PckStudio.Classes.Utils;
+using Microsoft.VisualBasic;
using OpenTK;
using OpenTK.Graphics.OpenGL;
-using Microsoft.VisualBasic;
+using System.Diagnostics;
+using PckStudio.Properties;
-namespace PckStudio.ToolboxItems
+namespace PckStudio.Rendering
{
- public partial class Renderer3D
+ public partial class Renderer3D : GLControl
{
- private Bitmap _Skin;
+ //private Bitmap _Skin;
///
/// The visible skin on the renderer
///
/// The visible skin
[Description("The current skin")]
[Category("Appearance")]
- public Bitmap Skin { get; set; }
+ public Bitmap Texture { get; set; }
private bool _showhead = true;
///
@@ -70,23 +73,23 @@ namespace PckStudio.ToolboxItems
return _showhead;
}
}
- private bool _show2ndhead = true;
+ private bool _showHeadOverlay = true;
///
/// Show the second head layer or not
///
/// Show the second head layer or not
[Description("Shows the second head layer or not")]
[Category("Appearance")]
- public bool Show2ndHead
+ public bool ShowHeadOverlay
{
set
{
Refresh();
- _show2ndhead = value;
+ _showHeadOverlay = value;
}
get
{
- return _show2ndhead;
+ return _showHeadOverlay;
}
}
private bool _showbody = true;
@@ -108,26 +111,26 @@ namespace PckStudio.ToolboxItems
return _showbody;
}
}
- private bool _show2ndbody = true;
+ private bool _showBodyOverlay = true;
///
/// Show the second body layer or not
///
/// Show the second body layer or not
[Description("Shows the second body layer or not")]
[Category("Appearance")]
- public bool Show2ndBody
+ public bool ShowBodyOverlay
{
set
{
Refresh();
- _show2ndbody = value;
+ _showBodyOverlay = value;
}
get
{
- return _show2ndbody;
+ return _showBodyOverlay;
}
}
- private bool _showra = true;
+ private bool _showRightArm = true;
///
/// Show the right arm or not
///
@@ -139,33 +142,33 @@ namespace PckStudio.ToolboxItems
set
{
Refresh();
- _showra = value;
+ _showRightArm = value;
}
get
{
- return _showra;
+ return _showRightArm;
}
}
- private bool _show2ndra = true;
+ private bool _showRightArmOverlay = true;
///
/// Show the second right arm layer or not
///
/// Show the second right arm layer or not
[Description("Shows the second right arm layer or not")]
[Category("Appearance")]
- public bool Show2ndRightArm
+ public bool ShowRightArmOverlay
{
set
{
Refresh();
- _show2ndra = value;
+ _showRightArmOverlay = value;
}
get
{
- return _show2ndra;
+ return _showRightArmOverlay;
}
}
- private bool _showla = true;
+ private bool _showLeftArm = true;
///
/// Show the left arm or not
///
@@ -177,33 +180,33 @@ namespace PckStudio.ToolboxItems
set
{
Refresh();
- _showla = value;
+ _showLeftArm = value;
}
get
{
- return _showla;
+ return _showLeftArm;
}
}
- private bool _show2ndla = true;
+ private bool _showLeftArmOverlay = true;
///
/// Show the second left arm layer or not
///
/// Show the second left arm layer or not
[Description("Shows the second left arm layer or not")]
[Category("Appearance")]
- public bool Show2ndLeftArm
+ public bool ShowLeftArmOverlay
{
set
{
Refresh();
- _show2ndla = value;
+ _showLeftArmOverlay = value;
}
get
{
- return _show2ndla;
+ return _showLeftArmOverlay;
}
}
- private bool _showrl = true;
+ private bool _showRightLeg = true;
///
/// Show the right leg or not
///
@@ -215,33 +218,33 @@ namespace PckStudio.ToolboxItems
set
{
Refresh();
- _showrl = value;
+ _showRightLeg = value;
}
get
{
- return _showrl;
+ return _showRightLeg;
}
}
- private bool _show2ndrl = true;
+ private bool _showRightLegOverlay = true;
///
/// Show the second right leg layer or not
///
/// Show the second right leg layer or not
[Description("Shows the second right leg layer or not")]
[Category("Appearance")]
- public bool Show2ndRightLeg
+ public bool ShowRightLegOverlay
{
set
{
Refresh();
- _show2ndrl = value;
+ _showRightLegOverlay = value;
}
get
{
- return _show2ndrl;
+ return _showRightLegOverlay;
}
}
- private bool _showll = true;
+ private bool _showLeftLeg = true;
///
/// Show the left leg or not
///
@@ -253,30 +256,30 @@ namespace PckStudio.ToolboxItems
set
{
Refresh();
- _showll = value;
+ _showLeftLeg = value;
}
get
{
- return _showll;
+ return _showLeftLeg;
}
}
- private bool _show2ndll = true;
+ private bool _showLeftLegOverlay = true;
///
/// Show the second left leg layer or not
///
/// Show the second left leg layer or not
[Description("Shows the second left leg layer or not")]
[Category("Appearance")]
- public bool Show2ndLeftLeg
+ public bool ShowLeftLegOverlay
{
set
{
Refresh();
- _show2ndll = value;
+ _showLeftLegOverlay = value;
}
get
{
- return _show2ndll;
+ return _showLeftLegOverlay;
}
}
@@ -310,119 +313,86 @@ namespace PckStudio.ToolboxItems
[Category("Appearance")]
public int RotationY { get; set; }
- private double _Zoom = 1d;
+ private double _Zoom = MinZoomLevel;
+ private const double MinZoomLevel = 1d;
+ private const double MaxZoomLevel = 10d;
+
[Description("The zoom value")]
[Category("Appearance")]
public double Zoom
{
- set
- {
- if (value < 1d)
- {
- value = 1d;
- }
- else if (value > 10d)
- {
- value = 10d;
- }
-
- _Zoom = value;
- }
- get
- {
- return _Zoom;
- }
+ get => _Zoom;
+ set => _Zoom = MathHelper.Clamp(value, MinZoomLevel, MaxZoomLevel);
}
- private double _LookX = 0d;
- [Description("The X axis offset from the orignal point (for zoom)")]
+ private PointF _lookAngle = PointF.Empty;
+
+ [Description("The offset from the orignal point (for zoom)")]
[Category("Appearance")]
- public double LookX
+ public PointF LookAngle
{
+ get => _lookAngle;
set
{
- if (value < -8)
+ if (value.X < -8f)
{
- value = -8;
+ value.X = -8f;
}
- else if (value > 8d)
+ else if (value.X > 8f)
{
- value = 8d;
+ value.X = 8f;
}
- _LookX = value;
- }
- get
- {
- return _LookX;
+ if (value.Y < -16f)
+ {
+ value.Y = -16f;
+ }
+ else if (value.Y > 16f)
+ {
+ value.Y = 16f;
+ }
+
+ _lookAngle = value;
}
}
+ private Matrix4 perspective; // Perspective
+ private Matrix4 camera; // Camera
- private double _LookY = 0d;
- [Description("The Y axis offset from the orignal point (for zoom)")]
- [Category("Appearance")]
- public double LookY
- {
- set
- {
- if (value < -16)
- {
- value = -16;
- }
- else if (value > 16d)
- {
- value = 16d;
- }
-
- _LookY = value;
- }
- get
- {
- return _LookY;
- }
- }
-
-
- [Description("Can paint on the skin")]
- [Category("Behavior")]
- public bool Paintable { get; set; } = true;
-
- ///
- /// Stop the paint faction
- ///
- /// Is stopped or not
- [Description("Render it or not (only used when design because when it became false in design mode it crashs VS and can be removed in the release)")]
- [Category("Behavior")]
- public bool InDesignMode { get; set; } = true;
-
- private Matrix4 perspective; // Setup Perspective
- private Matrix4 lookat; // Setup camera
+ private const double TexVal = 1d / 64d;
public Renderer3D()
{
- perspective = Matrix4.CreatePerspectiveFieldOfView((float)Math.Pow(Zoom, -1), (float)(Width / (double)Height), 1f, 100f);
- lookat = Matrix4.LookAt((float)LookX, (float)LookY, 36f, (float)LookX, (float)LookY, 0f, 0f, 1f, 1f);
- PaintThread = new System.Threading.Thread(PaintCommander);
InitializeComponent();
+ UpdateCamera();
+ UpdatePerspective();
+ //MakeCurrent();
+ //int program = CreateShader(Resources.vertexShader, Resources.fragment);
}
-
- private void DrawBox(float sizeX, float SizeY, float SizeZ, float X, float Y, float Z, float uvX, float uvY)
+ private void UpdateCamera()
{
- const double TexVal = 1d / 64d;
+ camera = Matrix4.LookAt(LookAngle.X, LookAngle.Y, 72f, LookAngle.X, LookAngle.Y, 0f, 0f, 1f, 1f);
+ }
+ private void UpdatePerspective()
+ {
+ perspective = Matrix4.CreatePerspectiveFieldOfView((float)Math.Pow(Zoom, -1), (float)(Width / (double)Height), 0.1f, 1000f);
+ }
+ // Only call when a context is present
+ private static void DrawBox(Image texture, Vector3 size, float X, float Y, float Z, float uvX, float uvY)
+ {
float[] Corner1 = { X, Y, Z };
- float[] Corner2 = { X + sizeX, Y, Z };
- float[] Corner3 = { X, Y + SizeY, Z };
- float[] Corner4 = { X, Y, Z + SizeZ };
- float[] Corner5 = { X + sizeX, Y + SizeY, Z };
- float[] Corner6 = { X, Y + SizeY, Z + SizeZ };
- float[] Corner7 = { X + sizeX, Y, Z + SizeZ };
- float[] Corner8 = { X + sizeX, Y + SizeY, Z + SizeZ };
-
+ float[] Corner2 = { X + size.X, Y, Z };
+ float[] Corner3 = { X, Y + size.Y, Z };
+ float[] Corner4 = { X, Y, Z + size.Z };
+ float[] Corner5 = { X + size.X, Y + size.Y, Z };
+ float[] Corner6 = { X, Y + size.Y, Z + size.Z };
+ float[] Corner7 = { X + size.X, Y, Z + size.Z };
+ float[] Corner8 = { X + size.X, Y + size.Y, Z + size.Z };
+ GL.Color3(Color.Red);
// Face 1
GL.Vertex3(Corner1);
GL.Vertex3(Corner3);
@@ -439,7 +409,7 @@ namespace PckStudio.ToolboxItems
GL.Vertex3(Corner6);
GL.Vertex3(Corner3);
// Face 4
- GL.TexCoord2(uvX + sizeX, TexVal * 8d);
+ GL.TexCoord2(uvX, TexVal * 8d);
GL.Vertex3(Corner4);
GL.TexCoord2(TexVal * 16d, TexVal * 8d);
GL.Vertex3(Corner7);
@@ -460,12 +430,55 @@ namespace PckStudio.ToolboxItems
}
- private void GlControl_Paint(object sender, PaintEventArgs e)
+ private static int CompileShader(ShaderType type, string shaderSource)
{
- if (InDesignMode)
- return;
+ int shaderId = GL.CreateShader(type);
+ GL.ShaderSource(shaderId, shaderSource);
+ GL.CompileShader(shaderId);
- GlControl.MakeCurrent();
+ GL.GetShader(shaderId, ShaderParameter.CompileStatus, out int status);
+
+ if (status == 0)
+ {
+ GL.GetShader(shaderId, ShaderParameter.InfoLogLength, out int length);
+ GL.GetShaderInfoLog(shaderId, length, out length, out string infoLog);
+ Trace.TraceError(infoLog);
+ GL.DeleteShader(shaderId);
+ return 0;
+ }
+ return shaderId;
+ }
+
+ private static int CreateShader(string vertexSource, string fragmentSource)
+ {
+ int programId = GL.CreateProgram();
+
+ int vertexShader = CompileShader(ShaderType.VertexShader, vertexSource);
+ int fragmentShader = CompileShader(ShaderType.FragmentShader, fragmentSource);
+
+ GL.AttachShader(programId, vertexShader);
+ GL.AttachShader(programId, fragmentShader);
+
+ GL.LinkProgram(programId);
+ GL.ValidateProgram(programId);
+
+ GL.DeleteShader(vertexShader);
+ GL.DeleteShader(fragmentShader);
+ return programId;
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if (DesignMode)
+ return;
+ //base.OnPaint(e);
+
+ MakeCurrent();
+#if DEBUG
+ debugLabel.Text = $"Rotation: {RotationX}, {RotationY}\nZoom: {_Zoom}\nLookAt:\n{camera}\nPerspective:\n{perspective}";
+#endif
+
+ GL.PushMatrix();
GL.ClearColor(BackColor);
// First Clear Buffers
@@ -473,15 +486,15 @@ namespace PckStudio.ToolboxItems
GL.Clear(ClearBufferMask.DepthBufferBit);
// Basic Setup for viewing
- perspective = Matrix4.CreatePerspectiveFieldOfView((float)Math.Pow(Zoom, -1), (float)(Width / (double)Height), 1f, 100f); // Setup Perspective
- lookat = Matrix4.LookAt((float)LookX, (float)LookY, 36f, (float)LookX, (float)LookY, 0f, 0f, 1f, 1f); // Setup camera
+ UpdatePerspective();
+ UpdateCamera();
GL.MatrixMode(MatrixMode.Projection); // Load Perspective
GL.LoadIdentity();
GL.LoadMatrix(ref perspective);
GL.MatrixMode(MatrixMode.Modelview); // Load Camera
GL.LoadIdentity();
- GL.LoadMatrix(ref lookat);
- GL.Viewport(0, 0, GlControl.Width, GlControl.Height); // Size of window
+ GL.LoadMatrix(ref camera);
+ GL.Viewport(0, 0, Width, Height); // Size of window
GL.Enable(EnableCap.DepthTest); // Enable correct Z Drawings
GL.Enable(EnableCap.Texture2D); // Enable textures
GL.DepthFunc(DepthFunction.Less); // Enable correct Z Drawings
@@ -489,28 +502,25 @@ namespace PckStudio.ToolboxItems
GL.Disable(EnableCap.AlphaTest); // Disable transparent
// Load the textures
- int texID = 1;
+ int texID = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, texID);
- var data = Skin.LockBits(new Rectangle(0, 0, 64, 64), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
+ var data = Texture.LockBits(new Rectangle(0, 0, 64, 64), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
+
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, 64, 64, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
- Skin.UnlockBits(data);
+ Texture.UnlockBits(data);
GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
- const double TexVal = 1d / 64d;
-
// Rotating
GL.Rotate(RotationX, -1, 0f, 0f);
GL.Rotate(RotationY, 0f, 1f, 0f);
GL.BindTexture(TextureTarget.ProxyTexture2D, texID);
// Vertex goes (X,Y,Z)
- GL.Begin(BeginMode.Quads);
+ GL.Begin(PrimitiveType.Quads);
// Body
- DrawBox(8, 8, 8, -4, 0, -2, 0, 0);
-
if (ShowBody)
{
@@ -990,18 +1000,17 @@ namespace PckStudio.ToolboxItems
GL.Vertex3(4, -16, -2);
GL.TexCoord2(TexVal * 24d, TexVal * 48d);
GL.Vertex3(0, -16, -2);
- }/*
- */
+ }
GL.End();
GL.Enable(EnableCap.AlphaTest); // Enable transparent
- GL.AlphaFunc(AlphaFunction.Greater, 0.4f);
- // GL.Enable(EnableCap.Blend) 'Enable transparent
- // GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.DstAlpha)
+ GL.AlphaFunc(AlphaFunction.Greater, 0.7f);
+ //GL.Enable(EnableCap.Blend); // Enable transparent
+ //GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.DstAlpha);
- GL.Begin(BeginMode.Quads);
- /*
- if (Show2ndBody)
+ GL.Begin(PrimitiveType.Quads);
+
+ if (ShowBodyOverlay)
{
// Face 1
GL.TexCoord2(TexVal * 20d, TexVal * 36d);
@@ -1059,7 +1068,7 @@ namespace PckStudio.ToolboxItems
GL.Vertex3(-4.24d, -4.36d, -2.12d);
}
- if (Show2ndHead)
+ if (ShowHeadOverlay)
{
// Head
// Face 1
@@ -1121,7 +1130,7 @@ namespace PckStudio.ToolboxItems
if (Model == Models.Steve)
{
- if (Show2ndLeftArm)
+ if (ShowLeftArmOverlay)
{
// LeftArm
// Face 1
@@ -1180,7 +1189,7 @@ namespace PckStudio.ToolboxItems
GL.Vertex3(3.88d, -4.36d, -2.12d);
}
- if (Show2ndRightArm)
+ if (ShowRightArmOverlay)
{
// RightArm
// Face 1
@@ -1243,7 +1252,7 @@ namespace PckStudio.ToolboxItems
else
{
- if (Show2ndLeftArm)
+ if (ShowLeftArmOverlay)
{
// LefttArm
// Face 1
@@ -1302,7 +1311,7 @@ namespace PckStudio.ToolboxItems
GL.Vertex3(3.91d, -4.36d, -2.12d);
}
- if (Show2ndRightArm)
+ if (ShowRightArmOverlay)
{
// RightArm
// Face 1
@@ -1363,7 +1372,7 @@ namespace PckStudio.ToolboxItems
}
- if (Show2ndRightLeg)
+ if (ShowRightLegOverlay)
{
// RightLeg
// Face 1
@@ -1422,7 +1431,7 @@ namespace PckStudio.ToolboxItems
GL.Vertex3(-4.12d, -16.36d, -2.12d);
}
- if (Show2ndLeftLeg)
+ if (ShowLeftLegOverlay)
{
// LeftLeg
// Face 1
@@ -1480,12 +1489,14 @@ namespace PckStudio.ToolboxItems
GL.TexCoord2(TexVal * 8d, TexVal * 48d);
GL.Vertex3(-0.12d, -16.36d, -2.12d);
}
- */
+
+ GL.DeleteTexture(texID);
+
// Finish the begin mode with "end"
GL.End();
-
+ GL.PopMatrix();
// Finally...
- GlControl.SwapBuffers(); // Takes from the 'GL' and puts into control
+ SwapBuffers(); // Takes from the 'GL' and puts into control
}
private bool IsMouseDown;
@@ -1499,39 +1510,13 @@ namespace PckStudio.ToolboxItems
public delegate void BeginChangedEventHandler(object sender, Bitmap LastSkin);
- private MouseRay GlobalMouseRay; // To use the var golbaly in the code
+ private Ray GlobalMouseRay; // To use the var golbaly in the code
private Vector3 GlobalCameraPos;
- private void GlControl_MouseDown(object sender, MouseEventArgs e)
+ protected override void OnMouseDown(MouseEventArgs e)
{
if (!IsMouseDown && e.Button == MouseButtons.Left) // Left mouse button
{
- if (Paintable) // Check if the Skin editor is paintable
- {
- GlControl.MakeCurrent();
- Matrix4 promatrix;
- Matrix4 viewmatrix;
- GL.GetFloat(GetPName.ModelviewMatrix, out viewmatrix);
- GL.GetFloat(GetPName.ProjectionMatrix, out promatrix);
- // Get the current mouse ray
- var m = new MouseRay(ref viewmatrix, ref promatrix, GlControl.Size, GetCameraPos(viewmatrix), this);
- m.Pos = e.Location;
- if (m.Mouse2ndHit != new Vector3(100f, 100f, 100f) || m.MouseHit != new Vector3(0f, 0f, 0f)) // Check if the mouse hit the model or no
- {
- Bitmap tmp = (Bitmap)Skin.Clone();
- BeginChanged?.Invoke(this, tmp); // Fire the event
- IsMouseHit = true;
-
- var CameraPos = GetCameraPos(viewmatrix);
- GlobalMouseRay = m;
- GlobalCameraPos = CameraPos;
-
- PaintThread = new System.Threading.Thread(PaintCommander);
- PaintThread.Start();
-
- return;
- }
- }
// If the ray didn't hit the model then rotate the model
OldLoc = Cursor.Position; // Store the old mouse position to reset it when the action is over
if (!IsMouseHidden) // Hide the mouse
@@ -1555,7 +1540,7 @@ namespace PckStudio.ToolboxItems
}
}
- private void GlControl_MouseUp(object sender, MouseEventArgs e)
+ protected override void OnMouseUp(MouseEventArgs e)
{
if (IsMouseHidden)
{
@@ -1580,103 +1565,29 @@ namespace PckStudio.ToolboxItems
}
else if (IsRightMouseDown) // Move the model
{
- LookX += -(Cursor.Position.X - MouseLoc.X) * 0.5d;
- LookY += (Cursor.Position.Y - MouseLoc.Y) * 0.5d;
+ float deltaX = -(Cursor.Position.X - MouseLoc.X) * 0.5f / (float)Zoom;
+ float deltaY = (Cursor.Position.Y - MouseLoc.Y) * 0.5f / (float)Zoom;
+ LookAngle = new PointF(LookAngle.X + deltaX, LookAngle.Y + deltaY);
Refresh();
Cursor.Position = new Point((int)Math.Round(Screen.PrimaryScreen.Bounds.Height / 2d), (int)Math.Round(Screen.PrimaryScreen.Bounds.Height / 2d));
MouseLoc = Cursor.Position;
}
}
- private void Renderer3D_MouseWheel(object sender, MouseEventArgs e) // Zoom
+ protected override void OnMouseWheel(MouseEventArgs e)
{
Zoom += e.Delta * 0.005d;
Refresh();
+ base.OnMouseWheel(e);
}
- private Vector3 GetCameraPos(Matrix4 modelview)
+ private Vector3 GetCameraPosition(Matrix4 modelview)
{
- GlControl.MakeCurrent();
return Matrix4.Invert(modelview).ExtractTranslation();
}
- private System.Threading.Thread PaintThread;
+
private List MousePoints = new List();
private List tmpMousePoints = new List();
- private bool PaintThreadSwitcher;
- private bool EndThreadFlag; // To make sure that the thread is done
-
- public void PaintCommander()
- {
- do
- {
- if (PaintThreadSwitcher)
- {
- if (tmpMousePoints.Count == 0)
- {
- tmpMousePoints.Add(Cursor.Position);
- }
- else if (!(tmpMousePoints.Last() == Cursor.Position))
- {
- tmpMousePoints.Add(Cursor.Position);
- }
- }
- else
- {
- MousePoints.AddRange(tmpMousePoints);
- tmpMousePoints.Clear();
- if (MousePoints.Count == 0)
- {
- MousePoints.Add(Cursor.Position);
- }
- else if (!(MousePoints.Last() == Cursor.Position))
- {
- MousePoints.Add(Cursor.Position);
- }
- }
- EndThreadFlag = false;
-
- if (IsMouseHit == false)
- {
- tmpMousePoints.Clear();
- MousePoints.Clear();
- PaintThread.Abort();
- }
- }
- while (true);
- }
-
- private void Paint_Tick(object sender, EventArgs e)
- {
- if (IsMouseHit)
- {
- PaintThreadSwitcher = true;
- EndThreadFlag = true;
- while (EndThreadFlag)
- {
- // Do nothing untill 'EndThreadFlag = False' then move on
- }
- foreach (Point P in MousePoints)
- {
- GlControl.Invoke(new Action(() => GlobalMouseRay.Pos = GlControl.PointToClient(P)));
- var Mouse2ndHit = GlobalMouseRay.Mouse2ndHit;
- var MouseHit = GlobalMouseRay.MouseHit;
- double MouseHitDis = Math.Sqrt(Math.Pow((double)(GlobalCameraPos.X - MouseHit.X), 2.0d) + Math.Pow((double)(GlobalCameraPos.Y - MouseHit.Y), 2.0d) + Math.Pow((double)(GlobalCameraPos.Z - MouseHit.Z), 2.0d));
- double Mouse2ndHitDis = Math.Sqrt(Math.Pow((double)(GlobalCameraPos.X - Mouse2ndHit.X), 2.0d) + Math.Pow((double)(GlobalCameraPos.Y - Mouse2ndHit.Y), 2.0d) + Math.Pow((double)(GlobalCameraPos.Z - Mouse2ndHit.Z), 2.0d));
- if (MouseHitDis > Mouse2ndHitDis)
- {
- PaintPixel(Mouse2ndHit, true);
- }
-
- else if (MouseHit != new Vector3(0f, 0f, 0f))
- {
- PaintPixel(MouseHit);
- }
- }
- MousePoints.Clear();
- PaintThreadSwitcher = false;
-
- }
- }
public event SkinChangedEventHandler SkinChanged;
@@ -1685,7 +1596,7 @@ namespace PckStudio.ToolboxItems
public void PaintPixel(Vector3 Vector, bool Second = false)
{
- Bitmap tmpSkin = (Bitmap)Skin.Clone();
+ Bitmap tmpSkin = (Bitmap)Texture.Clone();
Point Point;
var XUp = default(Vector3);
var YUp = default(Vector3);
@@ -2023,35 +1934,35 @@ namespace PckStudio.ToolboxItems
public Point Get2nd2DFrom3D(Vector3 Vector, ref Vector3 XUp, ref Vector3 YUp)
{
var Result = default(Point);
- if (Show2ndHead && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y < 16.24d && Vector.Y > 7.76d && Vector.Z == 4.24f)
+ if (ShowHeadOverlay && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y < 16.24d && Vector.Y > 7.76d && Vector.Z == 4.24f)
{
// ZHead
Result = new Point((int)Math.Round(Conversion.Int((Vector.X + 4.24d) / 1.06d + 40d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y + 16.24d) / 1.06d + 8d)));
XUp.X = 1f;
YUp.Y = 1f;
}
- else if (Show2ndHead && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y < 16.24d && Vector.Y > 7.76d && Vector.Z == -4.24f)
+ else if (ShowHeadOverlay && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y < 16.24d && Vector.Y > 7.76d && Vector.Z == -4.24f)
{
// ZHead
Result = new Point((int)Math.Round(Conversion.Int(((double)-Vector.X + 4.24d) / 1.06d + 56d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y + 16.24d) / 1.06d + 8d)));
XUp.X = 1f;
YUp.Y = 1f;
}
- else if (Show2ndBody && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.Z == 2.12f)
+ else if (ShowBodyOverlay && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.Z == 2.12f)
{
// ZBody
Result = new Point((int)Math.Round(Conversion.Int((Vector.X + 4.24d) / 1.06d + 20d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y + 8.36d) / 1.06d + 36d)));
XUp.X = 1f;
YUp.Y = 1f;
}
- else if (Show2ndBody && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.Z == -2.12f)
+ else if (ShowBodyOverlay && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.Z == -2.12f)
{
// ZBody
Result = new Point((int)Math.Round(Conversion.Int(((double)-Vector.X + 4.24d) / 1.06d + 32d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y + 8.36d) / 1.06d + 36d)));
XUp.X = 1f;
YUp.Y = 1f;
}
- else if (Show2ndRightArm && Vector.X < -3.88d && Vector.X > -8.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.Z == 2.12f)
+ else if (ShowRightArmOverlay && Vector.X < -3.88d && Vector.X > -8.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.Z == 2.12f)
{
// ZArms
if (Model == Models.Steve)
@@ -2065,7 +1976,7 @@ namespace PckStudio.ToolboxItems
XUp.X = 1f;
YUp.Y = 1f;
}
- else if (Show2ndRightArm && Vector.X < -3.88d && Vector.X > -8.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.Z == -2.12f)
+ else if (ShowRightArmOverlay && Vector.X < -3.88d && Vector.X > -8.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.Z == -2.12f)
{
// ZArms
if (Model == Models.Steve)
@@ -2079,14 +1990,14 @@ namespace PckStudio.ToolboxItems
XUp.X = 1f;
YUp.Y = 1f;
}
- else if (Show2ndLeftArm && Vector.X < 8.12d && Vector.X > 3.88d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.Z == 2.12f)
+ else if (ShowLeftArmOverlay && Vector.X < 8.12d && Vector.X > 3.88d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.Z == 2.12f)
{
// ZArms
Result = new Point((int)Math.Round(Conversion.Int((Vector.X + 3.88d) / 1.06d + 45d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y + 8.36d) / 1.06d + 52d)));
XUp.X = 1f;
YUp.Y = 1f;
}
- else if (Show2ndLeftArm && Vector.X < 8.12d && Vector.X > 3.88d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.Z == -2.12f)
+ else if (ShowLeftArmOverlay && Vector.X < 8.12d && Vector.X > 3.88d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.Z == -2.12f)
{
// ZArms
if (Model == Models.Steve)
@@ -2100,63 +2011,63 @@ namespace PckStudio.ToolboxItems
XUp.X = 1f;
YUp.Y = 1f;
}
- else if (Show2ndRightLeg && Vector.X < 0.12d && Vector.X > -4.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.Z == 2.12f)
+ else if (ShowRightLegOverlay && Vector.X < 0.12d && Vector.X > -4.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.Z == 2.12f)
{
// ZLegs
Result = new Point((int)Math.Round(Conversion.Int((Vector.X + 4.12d) / 1.06d + 4d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y - 16.36d) / 1.06d + 48d)));
XUp.X = 1f;
YUp.Y = 1f;
}
- else if (Show2ndRightLeg && Vector.X < 0.12d && Vector.X > -4.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.Z == -2.12f)
+ else if (ShowRightLegOverlay && Vector.X < 0.12d && Vector.X > -4.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.Z == -2.12f)
{
// ZLegs
Result = new Point((int)Math.Round(Conversion.Int(((double)-Vector.X + 4.12d) / 1.06d + 8d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y - 16.36d) / 1.06d + 48d)));
XUp.X = 1f;
YUp.Y = 1f;
}
- else if (Show2ndLeftLeg && Vector.X < 4.12d && Vector.X > -0.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.Z == 2.12f)
+ else if (ShowLeftLegOverlay && Vector.X < 4.12d && Vector.X > -0.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.Z == 2.12f)
{
// ZLegs
Result = new Point((int)Math.Round(Conversion.Int((Vector.X + 0.12d) / 1.06d + 4d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y - 3.64d) / 1.06d + 52d)));
XUp.X = 1f;
YUp.Y = 1f;
}
- else if (Show2ndLeftLeg && Vector.X < 4.12d && Vector.X > -0.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.Z == -2.12f)
+ else if (ShowLeftLegOverlay && Vector.X < 4.12d && Vector.X > -0.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.Z == -2.12f)
{
// ZLegs
Result = new Point((int)Math.Round(Conversion.Int(((double)-Vector.X + 0.12d) / 1.06d + 16d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y - 3.64d) / 1.06d + 52d)));
XUp.X = 1f;
YUp.Y = 1f;
}
- else if (Show2ndHead && Vector.Z < 4.24d && Vector.Z > -4.24d && Vector.Y < 16.24d && Vector.Y > 7.76d && Vector.X == 4.24f)
+ else if (ShowHeadOverlay && Vector.Z < 4.24d && Vector.Z > -4.24d && Vector.Y < 16.24d && Vector.Y > 7.76d && Vector.X == 4.24f)
{
// XHead
Result = new Point((int)Math.Round(Conversion.Int(((double)-Vector.Z + 4.24d) / 1.06d + 48d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y + 16.24d) / 1.06d + 8d)));
XUp.Z = 1f;
YUp.Y = 1f;
}
- else if (Show2ndHead && Vector.Z < 4.24d && Vector.Z > -4.24d && Vector.Y < 16.24d && Vector.Y > 7.76d && Vector.X == -4.24f)
+ else if (ShowHeadOverlay && Vector.Z < 4.24d && Vector.Z > -4.24d && Vector.Y < 16.24d && Vector.Y > 7.76d && Vector.X == -4.24f)
{
// XHead
Result = new Point((int)Math.Round(Conversion.Int((Vector.Z + 4.24d) / 1.06d + 32d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y + 16.24d) / 1.06d + 8d)));
XUp.Z = 1f;
YUp.Y = 1f;
}
- else if (Show2ndBody && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.X == 4.24f)
+ else if (ShowBodyOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.X == 4.24f)
{
// XBody
Result = new Point((int)Math.Round(Conversion.Int(((double)-Vector.Z + 2.12d) / 1.06d + 28d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y + 8.36d) / 1.06d + 36d)));
XUp.Z = 1f;
YUp.Y = 1f;
}
- else if (Show2ndBody && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.X == -4.24f)
+ else if (ShowBodyOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && Vector.X == -4.24f)
{
// XBody
Result = new Point((int)Math.Round(Conversion.Int((Vector.Z + 2.12d) / 1.06d + 16d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y + 8.36d) / 1.06d + 36d)));
XUp.Z = 1f;
YUp.Y = 1f;
}
- else if (Show2ndLeftArm && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && (Vector.X == 8.12f || Vector.X == 7.09f))
+ else if (ShowLeftArmOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && (Vector.X == 8.12f || Vector.X == 7.09f))
{
// XArms
if (Model == Models.Steve)
@@ -2170,21 +2081,21 @@ namespace PckStudio.ToolboxItems
XUp.Z = 1f;
YUp.Y = 1f;
}
- else if (Show2ndRightArm && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && (Vector.X == -8.12f || Vector.X == -7.09f))
+ else if (ShowRightArmOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && (Vector.X == -8.12f || Vector.X == -7.09f))
{
// XArms
Result = new Point((int)Math.Round(Conversion.Int((Vector.Z + 2.12d) / 1.06d + 40d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y + 8.36d) / 1.06d + 36d)));
XUp.Z = 1f;
YUp.Y = 1f;
}
- else if (Show2ndLeftArm && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && (Vector.X == 3.88f || Vector.X == 3.91f))
+ else if (ShowLeftArmOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && (Vector.X == 3.88f || Vector.X == 3.91f))
{
// XArms
Result = new Point((int)Math.Round(Conversion.Int((Vector.Z + 2.12d) / 1.06d + 48d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y + 8.36d) / 1.06d + 52d)));
XUp.Z = 1f;
YUp.Y = 1f;
}
- else if (Show2ndRightArm && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && (Vector.X == -3.88f || Vector.X == -3.91f))
+ else if (ShowRightArmOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < 8.36d && Vector.Y > -4.36d && (Vector.X == -3.88f || Vector.X == -3.91f))
{
// XArms
if (Model == Models.Steve)
@@ -2198,70 +2109,70 @@ namespace PckStudio.ToolboxItems
XUp.Z = 1f;
YUp.Y = 1f;
}
- else if (Show2ndLeftLeg && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.X == 4.24f)
+ else if (ShowLeftLegOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.X == 4.24f)
{
// XLeg
Result = new Point((int)Math.Round(Conversion.Int(((double)-Vector.Z + 2.12d) / 1.06d + 8d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y - 3.64d) / 1.06d + 52d)));
XUp.Z = 1f;
YUp.Y = 1f;
}
- else if (Show2ndRightLeg && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.X == -4.24f)
+ else if (ShowRightLegOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.X == -4.24f)
{
// XLeg
Result = new Point((int)Math.Round(Conversion.Int((Vector.Z + 2.12d) / 1.06d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y - 3.64d) / 1.06d + 36d)));
XUp.Z = 1f;
YUp.Y = 1f;
}
- else if (Show2ndRightLeg && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.X == 0.12f)
+ else if (ShowRightLegOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.X == 0.12f)
{
// XLeg
Result = new Point((int)Math.Round(Conversion.Int(((double)-Vector.Z + 2.12d) / 1.06d + 8d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y - 3.64d) / 1.06d + 36d)));
XUp.Z = 1f;
YUp.Y = 1f;
}
- else if (Show2ndLeftLeg && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.X == -0.12f)
+ else if (ShowLeftLegOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.Y < -3.64d && Vector.Y > -16.36d && Vector.X == -0.12f)
{
// XLeg
Result = new Point((int)Math.Round(Conversion.Int((Vector.Z + 2.12d) / 1.06d)), (int)Math.Round(Conversion.Int(((double)-Vector.Y - 3.64d) / 1.06d + 52d)));
XUp.Z = 1f;
YUp.Y = 1f;
}
- else if (Show2ndHead && Vector.Z < 4.24d && Vector.Z > -4.24d && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y == 16.24f)
+ else if (ShowHeadOverlay && Vector.Z < 4.24d && Vector.Z > -4.24d && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y == 16.24f)
{
// YHead
Result = new Point((int)Math.Round(Conversion.Int((Vector.X + 4.24d) / 1.06d + 40d)), (int)Math.Round(Conversion.Int((Vector.Z + 4.24d) / 1.06d)));
XUp.X = 1f;
YUp.Z = 1f;
}
- else if (Show2ndHead && Vector.Z < 4.24d && Vector.Z > -4.24d && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y == 7.76f)
+ else if (ShowHeadOverlay && Vector.Z < 4.24d && Vector.Z > -4.24d && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y == 7.76f)
{
// YHead
Result = new Point((int)Math.Round(Conversion.Int((Vector.X + 4.24d) / 1.06d + 48d)), (int)Math.Round(Conversion.Int((Vector.Z + 4.24d) / 1.06d)));
XUp.X = 1f;
YUp.Z = 1f;
}
- else if (Show2ndBody && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y == 8.36f)
+ else if (ShowBodyOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y == 8.36f)
{
// YBody
Result = new Point((int)Math.Round(Conversion.Int((Vector.X + 4.24d) / 1.06d + 20d)), (int)Math.Round(Conversion.Int((Vector.Z + 2.12d) / 1.06d + 32d)));
XUp.X = 1f;
YUp.Z = 1f;
}
- else if (Show2ndBody && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y == -4.36f)
+ else if (ShowBodyOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 4.24d && Vector.X > -4.24d && Vector.Y == -4.36f)
{
// YBody
Result = new Point((int)Math.Round(Conversion.Int((Vector.X + 4.24d) / 1.06d + 28d)), (int)Math.Round(Conversion.Int((Vector.Z + 2.12d) / 1.06d + 32d)));
XUp.X = 1f;
YUp.Z = 1f;
}
- else if (Show2ndLeftArm && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 8.12d && Vector.X > 3.88d && Vector.Y == 8.36f)
+ else if (ShowLeftArmOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 8.12d && Vector.X > 3.88d && Vector.Y == 8.36f)
{
// YArms
Result = new Point((int)Math.Round(Conversion.Int((Vector.X - 3.88d) / 1.06d + 52d)), (int)Math.Round(Conversion.Int((Vector.Z + 2.12d) / 1.06d + 48d)));
XUp.X = 1f;
YUp.Z = 1f;
}
- else if (Show2ndLeftArm && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 8.12d && Vector.X > 3.88d && Vector.Y == -4.36f)
+ else if (ShowLeftArmOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 8.12d && Vector.X > 3.88d && Vector.Y == -4.36f)
{
// YArms
if (Model == Models.Steve)
@@ -2275,7 +2186,7 @@ namespace PckStudio.ToolboxItems
XUp.X = 1f;
YUp.Z = 1f;
}
- else if (Show2ndRightArm && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < -3.88d && Vector.X > -8.12d && Vector.Y == 8.36f)
+ else if (ShowRightArmOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < -3.88d && Vector.X > -8.12d && Vector.Y == 8.36f)
{
// YArms
if (Model == Models.Steve)
@@ -2289,7 +2200,7 @@ namespace PckStudio.ToolboxItems
XUp.X = 1f;
YUp.Z = 1f;
}
- else if (Show2ndRightArm && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < -3.88d && Vector.X > -8.12d && Vector.Y == -4.36f)
+ else if (ShowRightArmOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < -3.88d && Vector.X > -8.12d && Vector.Y == -4.36f)
{
// YArms
if (Model == Models.Steve)
@@ -2303,28 +2214,28 @@ namespace PckStudio.ToolboxItems
XUp.X = 1f;
YUp.Z = 1f;
}
- else if (Show2ndLeftLeg && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 4.24d && Vector.X > -0.12d && Vector.Y == -3.64f)
+ else if (ShowLeftLegOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 4.24d && Vector.X > -0.12d && Vector.Y == -3.64f)
{
// YLeg
Result = new Point((int)Math.Round(Conversion.Int((Vector.X + 0.12d) / 1.06d + 4d)), (int)Math.Round(Conversion.Int((Vector.Z + 2.12d) / 1.06d + 48d)));
XUp.X = 1f;
YUp.Z = 1f;
}
- else if (Show2ndRightLeg && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 0.12d && Vector.X > -4.24d && Vector.Y == -3.64f)
+ else if (ShowRightLegOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 0.12d && Vector.X > -4.24d && Vector.Y == -3.64f)
{
// YLeg
Result = new Point((int)Math.Round(Conversion.Int((Vector.X + 4.24d) / 1.06d + 4d)), (int)Math.Round(Conversion.Int((Vector.Z + 2.12d) / 1.06d + 32d)));
XUp.X = 1f;
YUp.Z = 1f;
}
- else if (Show2ndLeftLeg && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 4.24d && Vector.X > -0.12d && Vector.Y == -16.36f)
+ else if (ShowLeftLegOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 4.24d && Vector.X > -0.12d && Vector.Y == -16.36f)
{
// YLeg
Result = new Point((int)Math.Round(Conversion.Int((Vector.X + 0.12d) / 1.06d + 8d)), (int)Math.Round(Conversion.Int((Vector.Z + 2.12d) / 1.06d + 48d)));
XUp.X = 1f;
YUp.Z = 1f;
}
- else if (Show2ndRightLeg && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 0.12d && Vector.X > -4.24d && Vector.Y == -16.36f)
+ else if (ShowRightLegOverlay && Vector.Z < 2.12d && Vector.Z > -2.12d && Vector.X < 0.12d && Vector.X > -4.24d && Vector.Y == -16.36f)
{
// YLeg
Result = new Point((int)Math.Round(Conversion.Int((Vector.X + 4.24d) / 1.06d + 8d)), (int)Math.Round(Conversion.Int((Vector.Z + 2.12d) / 1.06d + 32d)));
@@ -2367,7 +2278,7 @@ namespace PckStudio.ToolboxItems
public void FloodFill(int x, int y, Color new_color)
{
// Get the old and new colors.
- var old_color = Skin.GetPixel(x, y);
+ var old_color = Texture.GetPixel(x, y);
if (old_color.ToArgb() != new_color.ToArgb())
{
@@ -2428,25 +2339,25 @@ namespace PckStudio.ToolboxItems
{
case SkinPlace.Head:
{
- SkinSection = Skin.Clone(new Rectangle(0, 0, 32, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(0, 0, 32, 16), Texture.PixelFormat);
break;
}
case SkinPlace.Head2:
{
- SkinSection = Skin.Clone(new Rectangle(32, 0, 32, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(32, 0, 32, 16), Texture.PixelFormat);
x -= 32;
break;
}
case SkinPlace.Body:
{
- SkinSection = Skin.Clone(new Rectangle(16, 16, 24, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(16, 16, 24, 16), Texture.PixelFormat);
x -= 16;
y -= 16;
break;
}
case SkinPlace.Body2:
{
- SkinSection = Skin.Clone(new Rectangle(16, 32, 24, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(16, 32, 24, 16), Texture.PixelFormat);
x -= 16;
y -= 32;
break;
@@ -2455,11 +2366,11 @@ namespace PckStudio.ToolboxItems
{
if (Model == Models.Steve)
{
- SkinSection = Skin.Clone(new Rectangle(40, 16, 16, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(40, 16, 16, 16), Texture.PixelFormat);
}
else
{
- SkinSection = Skin.Clone(new Rectangle(40, 16, 14, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(40, 16, 14, 16), Texture.PixelFormat);
}
x -= 40;
y -= 16;
@@ -2469,11 +2380,11 @@ namespace PckStudio.ToolboxItems
{
if (Model == Models.Steve)
{
- SkinSection = Skin.Clone(new Rectangle(40, 32, 16, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(40, 32, 16, 16), Texture.PixelFormat);
}
else
{
- SkinSection = Skin.Clone(new Rectangle(40, 32, 14, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(40, 32, 14, 16), Texture.PixelFormat);
}
x -= 40;
y -= 32;
@@ -2483,11 +2394,11 @@ namespace PckStudio.ToolboxItems
{
if (Model == Models.Steve)
{
- SkinSection = Skin.Clone(new Rectangle(32, 48, 16, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(32, 48, 16, 16), Texture.PixelFormat);
}
else
{
- SkinSection = Skin.Clone(new Rectangle(32, 48, 14, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(32, 48, 14, 16), Texture.PixelFormat);
}
x -= 32;
y -= 48;
@@ -2497,11 +2408,11 @@ namespace PckStudio.ToolboxItems
{
if (Model == Models.Steve)
{
- SkinSection = Skin.Clone(new Rectangle(48, 48, 16, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(48, 48, 16, 16), Texture.PixelFormat);
}
else
{
- SkinSection = Skin.Clone(new Rectangle(48, 48, 14, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(48, 48, 14, 16), Texture.PixelFormat);
}
x -= 48;
y -= 48;
@@ -2509,26 +2420,26 @@ namespace PckStudio.ToolboxItems
}
case SkinPlace.RLeg:
{
- SkinSection = Skin.Clone(new Rectangle(0, 16, 16, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(0, 16, 16, 16), Texture.PixelFormat);
y -= 16;
break;
}
case SkinPlace.RLeg2:
{
- SkinSection = Skin.Clone(new Rectangle(0, 32, 16, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(0, 32, 16, 16), Texture.PixelFormat);
y -= 32;
break;
}
case SkinPlace.LLeg:
{
- SkinSection = Skin.Clone(new Rectangle(16, 48, 16, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(16, 48, 16, 16), Texture.PixelFormat);
x -= 16;
y -= 48;
break;
}
case SkinPlace.LLeg2:
{
- SkinSection = Skin.Clone(new Rectangle(0, 48, 16, 16), Skin.PixelFormat);
+ SkinSection = Texture.Clone(new Rectangle(0, 48, 16, 16), Texture.PixelFormat);
y -= 48;
break;
}
@@ -2687,30 +2598,30 @@ namespace PckStudio.ToolboxItems
}
- tmpG = Graphics.FromImage(Skin);
+ tmpG = Graphics.FromImage(Texture);
switch (CurrentPlace)
{
case SkinPlace.Head:
{
- TransparentFill(Skin, new Rectangle(0, 0, 32, 16));
+ TransparentFill(Texture, new Rectangle(0, 0, 32, 16));
tmpG.DrawImage(tmpSS, 0, 0, 32, 16);
break;
}
case SkinPlace.Head2:
{
- TransparentFill(Skin, new Rectangle(32, 0, 32, 16));
+ TransparentFill(Texture, new Rectangle(32, 0, 32, 16));
tmpG.DrawImage(tmpSS, 32, 0, 32, 16);
break;
}
case SkinPlace.Body:
{
- TransparentFill(Skin, new Rectangle(16, 16, 24, 16));
+ TransparentFill(Texture, new Rectangle(16, 16, 24, 16));
tmpG.DrawImage(tmpSS, 16, 16, 24, 16);
break;
}
case SkinPlace.Body2:
{
- TransparentFill(Skin, new Rectangle(16, 32, 24, 16));
+ TransparentFill(Texture, new Rectangle(16, 32, 24, 16));
tmpG.DrawImage(tmpSS, 16, 32, 24, 16);
break;
}
@@ -2718,12 +2629,12 @@ namespace PckStudio.ToolboxItems
{
if (Model == Models.Steve)
{
- TransparentFill(Skin, new Rectangle(40, 16, 16, 16));
+ TransparentFill(Texture, new Rectangle(40, 16, 16, 16));
tmpG.DrawImage(tmpSS, 40, 16, 16, 16);
}
else
{
- TransparentFill(Skin, new Rectangle(40, 16, 14, 16));
+ TransparentFill(Texture, new Rectangle(40, 16, 14, 16));
tmpG.DrawImage(tmpSS, 40, 16, 14, 16);
}
@@ -2733,12 +2644,12 @@ namespace PckStudio.ToolboxItems
{
if (Model == Models.Steve)
{
- TransparentFill(Skin, new Rectangle(40, 32, 16, 16));
+ TransparentFill(Texture, new Rectangle(40, 32, 16, 16));
tmpG.DrawImage(tmpSS, 40, 32, 16, 16);
}
else
{
- TransparentFill(Skin, new Rectangle(40, 32, 14, 16));
+ TransparentFill(Texture, new Rectangle(40, 32, 14, 16));
tmpG.DrawImage(tmpSS, 40, 32, 14, 16);
}
@@ -2748,12 +2659,12 @@ namespace PckStudio.ToolboxItems
{
if (Model == Models.Steve)
{
- TransparentFill(Skin, new Rectangle(32, 48, 16, 16));
+ TransparentFill(Texture, new Rectangle(32, 48, 16, 16));
tmpG.DrawImage(tmpSS, 32, 48, 16, 16);
}
else
{
- TransparentFill(Skin, new Rectangle(32, 48, 14, 16));
+ TransparentFill(Texture, new Rectangle(32, 48, 14, 16));
tmpG.DrawImage(tmpSS, 32, 48, 14, 16);
}
@@ -2763,12 +2674,12 @@ namespace PckStudio.ToolboxItems
{
if (Model == Models.Steve)
{
- TransparentFill(Skin, new Rectangle(48, 48, 16, 16));
+ TransparentFill(Texture, new Rectangle(48, 48, 16, 16));
tmpG.DrawImage(tmpSS, 48, 48, 16, 16);
}
else
{
- TransparentFill(Skin, new Rectangle(48, 48, 14, 16));
+ TransparentFill(Texture, new Rectangle(48, 48, 14, 16));
tmpG.DrawImage(tmpSS, 48, 48, 14, 16);
}
@@ -2776,25 +2687,25 @@ namespace PckStudio.ToolboxItems
}
case SkinPlace.RLeg:
{
- TransparentFill(Skin, new Rectangle(0, 16, 16, 16));
+ TransparentFill(Texture, new Rectangle(0, 16, 16, 16));
tmpG.DrawImage(tmpSS, 0, 16, 16, 16);
break;
}
case SkinPlace.RLeg2:
{
- TransparentFill(Skin, new Rectangle(0, 32, 16, 16));
+ TransparentFill(Texture, new Rectangle(0, 32, 16, 16));
tmpG.DrawImage(tmpSS, 0, 32, 16, 16);
break;
}
case SkinPlace.LLeg:
{
- TransparentFill(Skin, new Rectangle(16, 48, 16, 16));
+ TransparentFill(Texture, new Rectangle(16, 48, 16, 16));
tmpG.DrawImage(tmpSS, 16, 48, 16, 16);
break;
}
case SkinPlace.LLeg2:
{
- TransparentFill(Skin, new Rectangle(0, 48, 16, 16));
+ TransparentFill(Texture, new Rectangle(0, 48, 16, 16));
tmpG.DrawImage(tmpSS, 0, 48, 16, 16);
break;
}
@@ -3208,10 +3119,12 @@ namespace PckStudio.ToolboxItems
public void TransparentFill(Bitmap B, Rectangle R)
{
- for (int X = R.Left, loopTo = R.Right - 1; X <= loopTo; X++)
+ using (var g = Graphics.FromImage(B))
{
- for (int Y = R.Top, loopTo1 = R.Bottom - 1; Y <= loopTo1; Y++)
- B.SetPixel(X, Y, Color.Transparent);
+ var originClip = g.Clip;
+ g.Clip = new Region(R);
+ g.FillRectangle(new SolidBrush(Color.Transparent), R);
+ g.Clip = originClip;
}
}
}