mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-24 21:44:32 +00:00
Fixed SkinPreviewer and refactored/simplefied Model/Render related classes
This commit is contained in:
@@ -1,114 +1,115 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace PckStudio.Models
|
||||
{
|
||||
public class Box : global::PckStudio.Models.Object3D
|
||||
public class Box : Object3D
|
||||
{
|
||||
public override global::System.Drawing.Image Image
|
||||
public override Image Image
|
||||
{
|
||||
set
|
||||
{
|
||||
this.SetImage(value);
|
||||
SetImage(value);
|
||||
}
|
||||
}
|
||||
|
||||
internal override global::PckStudio.Models.MinecraftModelView Viewport
|
||||
internal override MinecraftModelView Viewport
|
||||
{
|
||||
set
|
||||
{
|
||||
base.Viewport = value;
|
||||
this.top.Viewport = value;
|
||||
this.bottom.Viewport = value;
|
||||
this.front.Viewport = value;
|
||||
this.back.Viewport = value;
|
||||
this.left.Viewport = value;
|
||||
this.right.Viewport = value;
|
||||
this.Update();
|
||||
top.Viewport = value;
|
||||
bottom.Viewport = value;
|
||||
front.Viewport = value;
|
||||
back.Viewport = value;
|
||||
left.Viewport = value;
|
||||
right.Viewport = value;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Update()
|
||||
{
|
||||
global::PckStudio.Models.Matrix3D a = this.globalTransformation * this.localTransformation;
|
||||
this.top.LocalTransformation = a * this.topLocalTransformation;
|
||||
this.bottom.LocalTransformation = a * this.bottomLocalTransformation;
|
||||
this.front.LocalTransformation = a * this.frontLocalTransformation;
|
||||
this.back.LocalTransformation = a * this.backLocalTransformation;
|
||||
this.left.LocalTransformation = a * this.leftLocalTransformation;
|
||||
this.right.LocalTransformation = a * this.rightLocalTransformation;
|
||||
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(global::System.Drawing.Image image, global::System.Drawing.Rectangle srcTopBottom, global::System.Drawing.Rectangle srcSides, global::PckStudio.Models.Point3D origin, global::PckStudio.Models.Effects effects)
|
||||
public Box(Image image, Rectangle srcTopBottom, Rectangle srcSides, Point3D origin, Effects effects)
|
||||
{
|
||||
this.effects = effects;
|
||||
base.Origin = origin;
|
||||
this.SetImage(image, srcTopBottom, srcSides);
|
||||
Origin = origin;
|
||||
SetImage(image, srcTopBottom, srcSides);
|
||||
}
|
||||
|
||||
private void SetImage(global::System.Drawing.Image image, global::System.Drawing.Rectangle srcTopBottom, global::System.Drawing.Rectangle srcSides)
|
||||
private void SetImage(Image image, Rectangle srcTopBottom, Rectangle srcSides)
|
||||
{
|
||||
int num = srcTopBottom.Width / 2;
|
||||
int height = srcSides.Height;
|
||||
int height2 = srcTopBottom.Height;
|
||||
this.srcTop = new global::System.Drawing.Rectangle(srcTopBottom.Location, new global::System.Drawing.Size(num, height2));
|
||||
this.srcBottom = new global::System.Drawing.Rectangle(srcTopBottom.X + num, srcTopBottom.Y, num, height2);
|
||||
this.srcFront = new global::System.Drawing.Rectangle(srcSides.X + height2, srcSides.Y, num, height);
|
||||
this.srcBack = new global::System.Drawing.Rectangle(srcSides.X + height2 + num + height2, srcSides.Y, num, height);
|
||||
this.srcLeft = new global::System.Drawing.Rectangle(srcSides.Location, new global::System.Drawing.Size(height2, height));
|
||||
this.srcRight = new global::System.Drawing.Rectangle(srcSides.X + height2 + num, srcSides.Y, height2, height);
|
||||
this.SetImage(image);
|
||||
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(global::System.Drawing.Image image)
|
||||
private void SetImage(Image image)
|
||||
{
|
||||
bool flag = (byte)(this.effects & global::PckStudio.Models.Effects.FlipHorizontally) == 1;
|
||||
bool flag2 = (byte)(this.effects & global::PckStudio.Models.Effects.FlipVertically) == 2;
|
||||
int width = this.srcFront.Width;
|
||||
int height = this.srcFront.Height;
|
||||
int width2 = this.srcLeft.Width;
|
||||
this.top = new global::PckStudio.Models.TexturePlane(image, flag2 ? this.srcBottom : this.srcTop, new global::PckStudio.Models.Point3D((float)width * 0.5f, (float)width2 * 0.5f, (float)(-(float)height) * 0.5f), new global::PckStudio.Models.Point3D(0f, 1f, 0f), this.effects & global::PckStudio.Models.Effects.FlipHorizontally);
|
||||
this.bottom = new global::PckStudio.Models.TexturePlane(image, flag2 ? this.srcTop : this.srcBottom, new global::PckStudio.Models.Point3D((float)width / 2f, (float)width2 / 2f, (float)height / 2f), new global::PckStudio.Models.Point3D(0f, -1f, 0f), this.effects & global::PckStudio.Models.Effects.FlipHorizontally);
|
||||
this.front = new global::PckStudio.Models.TexturePlane(image, this.srcFront, new global::PckStudio.Models.Point3D((float)width * 0.5f, (float)height * 0.5f, (float)(-(float)width2) * 0.5f), new global::PckStudio.Models.Point3D(0f, 0f, 1f), this.effects);
|
||||
this.back = new global::PckStudio.Models.TexturePlane(image, this.srcBack, new global::PckStudio.Models.Point3D((float)width * 0.5f, (float)height * 0.5f, (float)(-(float)width2) * 0.5f), new global::PckStudio.Models.Point3D(0f, 0f, -1f), this.effects);
|
||||
this.left = new global::PckStudio.Models.TexturePlane(image, flag ? this.srcRight : this.srcLeft, new global::PckStudio.Models.Point3D((float)width2 * 0.5f, (float)height * 0.5f, (float)(-(float)width) * 0.5f), new global::PckStudio.Models.Point3D(-1f, 0f, 0f), this.effects);
|
||||
this.right = new global::PckStudio.Models.TexturePlane(image, flag ? this.srcLeft : this.srcRight, new global::PckStudio.Models.Point3D((float)width2 * 0.5f, (float)height * 0.5f, (float)(-(float)width) * 0.5f), new global::PckStudio.Models.Point3D(1f, 0f, 0f), this.effects);
|
||||
this.top.Viewport = this.viewport;
|
||||
this.bottom.Viewport = this.viewport;
|
||||
this.front.Viewport = this.viewport;
|
||||
this.back.Viewport = this.viewport;
|
||||
this.left.Viewport = this.viewport;
|
||||
this.right.Viewport = this.viewport;
|
||||
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(global::System.Drawing.PointF location)
|
||||
public override float HitTest(PointF location)
|
||||
{
|
||||
float num = -1000f;
|
||||
float num2 = this.top.HitTest(location);
|
||||
float num2 = top.HitTest(location);
|
||||
if (num2 > num)
|
||||
{
|
||||
num = num2;
|
||||
}
|
||||
num2 = this.bottom.HitTest(location);
|
||||
num2 = bottom.HitTest(location);
|
||||
if (num2 > num)
|
||||
{
|
||||
num = num2;
|
||||
}
|
||||
num2 = this.front.HitTest(location);
|
||||
num2 = front.HitTest(location);
|
||||
if (num2 > num)
|
||||
{
|
||||
num = num2;
|
||||
}
|
||||
num2 = this.back.HitTest(location);
|
||||
num2 = back.HitTest(location);
|
||||
if (num2 > num)
|
||||
{
|
||||
num = num2;
|
||||
}
|
||||
num2 = this.left.HitTest(location);
|
||||
num2 = left.HitTest(location);
|
||||
if (num2 > num)
|
||||
{
|
||||
num = num2;
|
||||
}
|
||||
num2 = this.right.HitTest(location);
|
||||
num2 = right.HitTest(location);
|
||||
if (num2 > num)
|
||||
{
|
||||
num = num2;
|
||||
@@ -116,42 +117,42 @@ namespace PckStudio.Models
|
||||
return num;
|
||||
}
|
||||
|
||||
private global::PckStudio.Models.TexturePlane top;
|
||||
private TexturePlane top;
|
||||
|
||||
private global::PckStudio.Models.TexturePlane bottom;
|
||||
private TexturePlane bottom;
|
||||
|
||||
private global::PckStudio.Models.TexturePlane front;
|
||||
private TexturePlane front;
|
||||
|
||||
private global::PckStudio.Models.TexturePlane back;
|
||||
private TexturePlane back;
|
||||
|
||||
private global::PckStudio.Models.TexturePlane left;
|
||||
private TexturePlane left;
|
||||
|
||||
private global::PckStudio.Models.TexturePlane right;
|
||||
private TexturePlane right;
|
||||
|
||||
private global::System.Drawing.Rectangle srcTop;
|
||||
private Rectangle srcTop;
|
||||
|
||||
private global::System.Drawing.Rectangle srcBottom;
|
||||
private Rectangle srcBottom;
|
||||
|
||||
private global::System.Drawing.Rectangle srcFront;
|
||||
private Rectangle srcFront;
|
||||
|
||||
private global::System.Drawing.Rectangle srcBack;
|
||||
private Rectangle srcBack;
|
||||
|
||||
private global::System.Drawing.Rectangle srcLeft;
|
||||
private Rectangle srcLeft;
|
||||
|
||||
private global::System.Drawing.Rectangle srcRight;
|
||||
private Rectangle srcRight;
|
||||
|
||||
private global::PckStudio.Models.Matrix3D topLocalTransformation = global::PckStudio.Models.Matrix3D.CreateRotationX(-1.57079637f);
|
||||
private Matrix3D topLocalTransformation = Matrix3D.CreateRotationX(-1.57079637f);
|
||||
|
||||
private global::PckStudio.Models.Matrix3D bottomLocalTransformation = global::PckStudio.Models.Matrix3D.CreateRotationX(-1.57079637f);
|
||||
private Matrix3D bottomLocalTransformation = Matrix3D.CreateRotationX(-1.57079637f);
|
||||
|
||||
private global::PckStudio.Models.Matrix3D frontLocalTransformation = global::PckStudio.Models.Matrix3D.Identity;
|
||||
private Matrix3D frontLocalTransformation = Matrix3D.Identity;
|
||||
|
||||
private global::PckStudio.Models.Matrix3D backLocalTransformation = global::PckStudio.Models.Matrix3D.CreateRotationY(3.14159274f);
|
||||
private Matrix3D backLocalTransformation = Matrix3D.CreateRotationY(3.14159274f);
|
||||
|
||||
private global::PckStudio.Models.Matrix3D leftLocalTransformation = global::PckStudio.Models.Matrix3D.CreateRotationY(-1.57079637f);
|
||||
private Matrix3D leftLocalTransformation = Matrix3D.CreateRotationY(-1.57079637f);
|
||||
|
||||
private global::PckStudio.Models.Matrix3D rightLocalTransformation = global::PckStudio.Models.Matrix3D.CreateRotationY(1.57079637f);
|
||||
private Matrix3D rightLocalTransformation = Matrix3D.CreateRotationY(1.57079637f);
|
||||
|
||||
private global::PckStudio.Models.Effects effects;
|
||||
private Effects effects;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using PckStudio.Models;
|
||||
using PckStudio.Properties;
|
||||
|
||||
namespace PckStudio.Models
|
||||
{
|
||||
internal class CharacterModel : ModelBase
|
||||
{
|
||||
public CharacterModel()
|
||||
{
|
||||
}
|
||||
|
||||
protected override Texture[] InitializeTextures()
|
||||
{
|
||||
return new Texture[0];
|
||||
}
|
||||
|
||||
public override void AddToModelView(MinecraftModelView modelView)
|
||||
{
|
||||
Image source = base.Textures[0].Source;
|
||||
Object3D object3D = new Box(source, new Rectangle(8, 0, 0x10, 8), new Rectangle(0, 8, 0x20, 8), new Point3D(0f, 0f, 0f), Effects.None);
|
||||
Object3D object3D2 = new Box(source, new Rectangle(0x28, 0, 0x10, 8), new Rectangle(0x20, 8, 0x20, 8), new Point3D(0f, 0f, 0f), Effects.None);
|
||||
Object3D object3D3 = new Box(source, new Rectangle(0x2C, 0x10, 8, 4), new Rectangle(0x28, 0x14, 0x20, 0xC), new Point3D(0f, 4f, 0f), Effects.FlipHorizontally);
|
||||
Object3D object3D4 = new Box(source, new Rectangle(0x2C, 0x10, 8, 4), new Rectangle(0x28, 0x14, 0x20, 0xC), new Point3D(0f, 4f, 0f), Effects.None);
|
||||
Object3D object3D5 = new Box(source, new Rectangle(4, 0x10, 8, 4), new Rectangle(0, 0x14, 0x10, 0xC), new Point3D(0f, 6f, 0f), Effects.FlipHorizontally);
|
||||
Object3D object3D6 = new Box(source, new Rectangle(4, 0x10, 8, 4), new Rectangle(0, 0x14, 0x10, 0xC), new Point3D(0f, 6f, 0f), Effects.None);
|
||||
Object3D object3D7 = new Box(source, new Rectangle(0x14, 0x10, 0x10, 4), new Rectangle(0x10, 0x14, 0x18, 0xC), new Point3D(0f, 0f, 0f), Effects.None);
|
||||
Object3DGroup object3DGroup = new Object3DGroup();
|
||||
object3D2.Scale = 1.16f;
|
||||
object3DGroup.RotationOrder = RotationOrders.XY;
|
||||
object3DGroup.MinDegrees1 = -80f;
|
||||
object3DGroup.MaxDegrees1 = 80f;
|
||||
object3DGroup.MinDegrees2 = -57f;
|
||||
object3DGroup.MaxDegrees2 = 57f;
|
||||
object3DGroup.Add(object3D);
|
||||
object3DGroup.Add(object3D2);
|
||||
object3DGroup.Position = new Point3D(0f, 8f, 0f);
|
||||
object3DGroup.Origin = new Point3D(0f, -4f, 0f);
|
||||
object3DGroup.RotationOrder = RotationOrders.XY;
|
||||
object3D7.Position = new Point3D(0f, 2f, 0f);
|
||||
object3D3.Position = new Point3D(6f, 6f, 0f);
|
||||
object3D3.RotationOrder = RotationOrders.ZX;
|
||||
object3D3.MinDegrees1 = 0f;
|
||||
object3D3.MaxDegrees1 = 160f;
|
||||
object3D3.MinDegrees2 = -170f;
|
||||
object3D3.MaxDegrees2 = 60f;
|
||||
object3D4.Position = new Point3D(-6f, 6f, 0f);
|
||||
object3D4.RotationOrder = RotationOrders.ZX;
|
||||
object3D4.MinDegrees1 = -160f;
|
||||
object3D4.MaxDegrees1 = 0f;
|
||||
object3D4.MinDegrees2 = -170f;
|
||||
object3D4.MaxDegrees2 = 60f;
|
||||
object3D5.Position = new Point3D(2f, -4f, 0f);
|
||||
object3D5.RotationOrder = RotationOrders.ZX;
|
||||
object3D5.MinDegrees1 = 0f;
|
||||
object3D5.MaxDegrees1 = 70f;
|
||||
object3D5.MinDegrees2 = -110f;
|
||||
object3D5.MaxDegrees2 = 60f;
|
||||
object3D6.Position = new Point3D(-2f, -4f, 0f);
|
||||
object3D6.RotationOrder = RotationOrders.ZX;
|
||||
object3D6.MinDegrees1 = -70f;
|
||||
object3D6.MaxDegrees1 = 0f;
|
||||
object3D6.MinDegrees2 = -110f;
|
||||
object3D6.MaxDegrees2 = 60f;
|
||||
modelView.AddDynamic(object3DGroup);
|
||||
modelView.AddStatic(object3D7);
|
||||
modelView.AddDynamic(object3D4);
|
||||
modelView.AddDynamic(object3D3);
|
||||
modelView.AddDynamic(object3D6);
|
||||
modelView.AddDynamic(object3D5);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Character";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,57 +7,46 @@ namespace PckStudio.Models
|
||||
{
|
||||
public abstract class ModelBase
|
||||
{
|
||||
|
||||
|
||||
public ModelBase()
|
||||
{
|
||||
textures = InitializeTextures();
|
||||
foreach (Texture texture in textures)
|
||||
{
|
||||
texture.Updatedx += delegate(object sender, System.EventArgs args)
|
||||
{
|
||||
OnUpdated();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{ }
|
||||
|
||||
public Texture[] textures;
|
||||
|
||||
public System.EventHandler Updated;
|
||||
public EventHandler OnUpdate;
|
||||
|
||||
public Texture[] Textures
|
||||
protected void Initialize()
|
||||
{
|
||||
get
|
||||
{
|
||||
return textures;
|
||||
}
|
||||
}
|
||||
foreach (Texture texture in textures)
|
||||
{
|
||||
texture.Updatedx += (object sender, EventArgs args) => OnUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
public event System.EventHandler Updatedx
|
||||
public Texture[] Textures => textures;
|
||||
|
||||
public event EventHandler Updatedx
|
||||
{
|
||||
add
|
||||
{
|
||||
System.EventHandler eventHandler = Updated;
|
||||
System.EventHandler eventHandler2;
|
||||
EventHandler eventHandler = OnUpdate;
|
||||
EventHandler eventHandler2;
|
||||
do
|
||||
{
|
||||
eventHandler2 = eventHandler;
|
||||
System.EventHandler value2 = (System.EventHandler)System.Delegate.Combine(eventHandler2, value);
|
||||
eventHandler = System.Threading.Interlocked.CompareExchange<System.EventHandler>(ref Updated, value2, eventHandler2);
|
||||
EventHandler value2 = (EventHandler)Delegate.Combine(eventHandler2, value);
|
||||
eventHandler = Interlocked.CompareExchange(ref OnUpdate, value2, eventHandler2);
|
||||
}
|
||||
while (eventHandler != eventHandler2);
|
||||
}
|
||||
remove
|
||||
{
|
||||
System.EventHandler eventHandler = Updated;
|
||||
System.EventHandler eventHandler2;
|
||||
EventHandler eventHandler = OnUpdate;
|
||||
EventHandler eventHandler2;
|
||||
do
|
||||
{
|
||||
eventHandler2 = eventHandler;
|
||||
System.EventHandler value2 = (System.EventHandler)System.Delegate.Remove(eventHandler2, value);
|
||||
eventHandler = System.Threading.Interlocked.CompareExchange<System.EventHandler>(ref Updated, value2, eventHandler2);
|
||||
EventHandler value2 = (EventHandler)Delegate.Remove(eventHandler2, value);
|
||||
eventHandler = Interlocked.CompareExchange(ref OnUpdate, value2, eventHandler2);
|
||||
}
|
||||
while (eventHandler != eventHandler2);
|
||||
}
|
||||
@@ -65,21 +54,12 @@ namespace PckStudio.Models
|
||||
|
||||
protected void OnUpdated()
|
||||
{
|
||||
if (Updated != null)
|
||||
if (OnUpdate != null)
|
||||
{
|
||||
Updated(this, System.EventArgs.Empty);
|
||||
OnUpdate(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Texture[] InitializeTextures();
|
||||
|
||||
public abstract void AddToModelView(MinecraftModelView modelView);
|
||||
|
||||
[System.Runtime.CompilerServices.CompilerGenerated]
|
||||
private void b__0(object sender, System.EventArgs args)
|
||||
{
|
||||
OnUpdated();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
89
PCK-Studio/Classes/Models/DefaultModels/Steve64x32Model.cs
Normal file
89
PCK-Studio/Classes/Models/DefaultModels/Steve64x32Model.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using PckStudio.Models;
|
||||
using PckStudio.Properties;
|
||||
|
||||
namespace PckStudio.Models
|
||||
{
|
||||
internal class Steve64x32Model : ModelBase
|
||||
{
|
||||
public Steve64x32Model(Texture texture)
|
||||
{
|
||||
textures = new Texture[1] { texture };
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public override void AddToModelView(MinecraftModelView modelView)
|
||||
{
|
||||
_ = Textures[0] ?? throw new NullReferenceException(nameof(Textures));
|
||||
Image source = Textures[0].Source;
|
||||
Box head = new Box(source, new Rectangle(8, 0, 16, 8), new Rectangle(0, 8, 32, 8), new Point3D(0f, 0f, 0f), Effects.None);
|
||||
Box headOverlay = new Box(source, new Rectangle(40, 0, 16, 8), new Rectangle(32, 8, 32, 8), new Point3D(0f, 0f, 0f), Effects.None);
|
||||
|
||||
Box body = new Box(source, new Rectangle(20, 16, 16, 4), new Rectangle(16, 20, 24, 12), new Point3D(0f, 0f, 0f), Effects.None);
|
||||
|
||||
Box leftArm = new Box(source, new Rectangle(44, 16, 8, 4), new Rectangle(40, 20, 32, 12), new Point3D(0f, 4f, 0f), Effects.FlipHorizontally);
|
||||
Box rightArm = new Box(source, new Rectangle(44, 16, 8, 4), new Rectangle(40, 20, 32, 12), new Point3D(0f, 4f, 0f), Effects.None);
|
||||
|
||||
Box leftLeg = new Box(source, new Rectangle(4, 16, 8, 4), new Rectangle(0, 20, 16, 12), new Point3D(0f, 6f, 0f), Effects.FlipHorizontally);
|
||||
Box rightLeg = new Box(source, new Rectangle(4, 16, 8, 4), new Rectangle(0, 20, 16, 12), new Point3D(0f, 6f, 0f), Effects.None);
|
||||
|
||||
Object3DGroup headGroup = new Object3DGroup();
|
||||
|
||||
headGroup.RotationOrder = RotationOrders.XY;
|
||||
headGroup.MinDegrees1 = -80f;
|
||||
headGroup.MaxDegrees1 = 80f;
|
||||
|
||||
headGroup.MinDegrees2 = -57f;
|
||||
headGroup.MaxDegrees2 = 57f;
|
||||
|
||||
headOverlay.Scale = 1.16f;
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -8,133 +8,99 @@ namespace PckStudio.Models
|
||||
{
|
||||
public class Texture
|
||||
{
|
||||
public System.Drawing.Size Size
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.defaultSource.Size;
|
||||
}
|
||||
}
|
||||
public Size Size => defaultSource.Size;
|
||||
|
||||
public int Width
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.defaultSource.Width;
|
||||
}
|
||||
}
|
||||
public int Width => defaultSource.Width;
|
||||
|
||||
public int Height => defaultSource.Height;
|
||||
|
||||
public int Height
|
||||
public Image Source
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.defaultSource.Height;
|
||||
}
|
||||
}
|
||||
|
||||
public System.Drawing.Image Source
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.customSource != null)
|
||||
{
|
||||
return this.customSource;
|
||||
}
|
||||
return this.defaultSource;
|
||||
return customSource ?? defaultSource;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == this.customSource)
|
||||
if (value == customSource)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (value == null)
|
||||
{
|
||||
this.customSource = null;
|
||||
customSource = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value.Width != this.defaultSource.Width || value.Height != this.defaultSource.Height)
|
||||
if (value.Width != defaultSource.Width || value.Height != defaultSource.Height)
|
||||
{
|
||||
throw new System.ArgumentException("Tekstura ma nieodpowiedni rozmiar");
|
||||
throw new ArgumentException("The texture is not the correct size");
|
||||
}
|
||||
this.customSource = value;
|
||||
customSource = value;
|
||||
}
|
||||
this.OnUpdated();
|
||||
OnUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public string FileName
|
||||
{
|
||||
[System.Runtime.CompilerServices.CompilerGenerated]
|
||||
get
|
||||
{
|
||||
return this.k__BackingField;
|
||||
}
|
||||
[System.Runtime.CompilerServices.CompilerGenerated]
|
||||
set
|
||||
{
|
||||
this.k__BackingField = value;
|
||||
}
|
||||
}
|
||||
public string FileName { get; set; }
|
||||
|
||||
public event System.EventHandler Updatedx
|
||||
public event EventHandler Updatedx
|
||||
{
|
||||
add
|
||||
{
|
||||
System.EventHandler eventHandler = this.Updated;
|
||||
System.EventHandler eventHandler2;
|
||||
EventHandler eventHandler = Update;
|
||||
EventHandler eventHandler2;
|
||||
do
|
||||
{
|
||||
eventHandler2 = eventHandler;
|
||||
System.EventHandler value2 = (System.EventHandler)System.Delegate.Combine(eventHandler2, value);
|
||||
eventHandler = System.Threading.Interlocked.CompareExchange<System.EventHandler>(ref this.Updated, value2, eventHandler2);
|
||||
EventHandler value2 = (EventHandler)Delegate.Combine(eventHandler2, value);
|
||||
eventHandler = Interlocked.CompareExchange(ref Update, value2, eventHandler2);
|
||||
}
|
||||
while (eventHandler != eventHandler2);
|
||||
}
|
||||
remove
|
||||
{
|
||||
System.EventHandler eventHandler = this.Updated;
|
||||
System.EventHandler eventHandler2;
|
||||
EventHandler eventHandler = Update;
|
||||
EventHandler eventHandler2;
|
||||
do
|
||||
{
|
||||
eventHandler2 = eventHandler;
|
||||
System.EventHandler value2 = (System.EventHandler)System.Delegate.Remove(eventHandler2, value);
|
||||
eventHandler = System.Threading.Interlocked.CompareExchange<System.EventHandler>(ref this.Updated, value2, eventHandler2);
|
||||
EventHandler value2 = (EventHandler)Delegate.Remove(eventHandler2, value);
|
||||
eventHandler = Interlocked.CompareExchange(ref Update, value2, eventHandler2);
|
||||
}
|
||||
while (eventHandler != eventHandler2);
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnUpdated()
|
||||
protected void OnUpdate()
|
||||
{
|
||||
if (this.Updated != null)
|
||||
if (Update != null)
|
||||
{
|
||||
this.Updated(this, System.EventArgs.Empty);
|
||||
Update(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public Texture(System.Drawing.Image defaultSource)
|
||||
public static implicit operator Texture(Image image) => new Texture(image);
|
||||
|
||||
public Texture(Image defaultSource, Image customSource = null)
|
||||
{
|
||||
this.defaultSource = defaultSource;
|
||||
this.customSource = customSource;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (this.customSource != null)
|
||||
if (customSource != null)
|
||||
{
|
||||
return System.IO.Path.GetFileName(this.FileName);
|
||||
return Path.GetFileName(FileName);
|
||||
}
|
||||
return this.defaultSource.Width + " x " + this.defaultSource.Height;
|
||||
return defaultSource.Width + " x " + defaultSource.Height;
|
||||
}
|
||||
|
||||
private System.Drawing.Image defaultSource;
|
||||
private Image defaultSource;
|
||||
|
||||
private System.Drawing.Image customSource;
|
||||
private Image customSource;
|
||||
|
||||
private System.EventHandler Updated;
|
||||
|
||||
[System.Runtime.CompilerServices.CompilerGenerated]
|
||||
private string k__BackingField;
|
||||
private EventHandler Update;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace PckStudio.Models
|
||||
{
|
||||
[global::System.Flags]
|
||||
[Flags]
|
||||
public enum Effects : byte
|
||||
{
|
||||
None = 0,
|
||||
|
||||
@@ -6,140 +6,140 @@ namespace PckStudio.Models
|
||||
{
|
||||
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)
|
||||
{
|
||||
this.M11 = m11;
|
||||
this.M12 = m12;
|
||||
this.M13 = m13;
|
||||
this.M14 = m14;
|
||||
this.M21 = m21;
|
||||
this.M22 = m22;
|
||||
this.M23 = m23;
|
||||
this.M24 = m24;
|
||||
this.M31 = m31;
|
||||
this.M32 = m32;
|
||||
this.M33 = m33;
|
||||
this.M34 = m34;
|
||||
this.M41 = m41;
|
||||
this.M42 = m42;
|
||||
this.M43 = m43;
|
||||
this.M44 = 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 global::PckStudio.Models.Matrix3D CreateRotationX(float radians)
|
||||
public static Matrix3D CreateRotationX(float radians)
|
||||
{
|
||||
float num = (float)global::System.Math.Sin((double)radians);
|
||||
float num2 = (float)global::System.Math.Cos((double)radians);
|
||||
return new global::PckStudio.Models.Matrix3D(1f, 0f, 0f, 0f, 0f, num2, -num, 0f, 0f, num, num2, 0f, 0f, 0f, 0f, 1f);
|
||||
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 global::PckStudio.Models.Matrix3D CreateRotationX(float sin, float cos)
|
||||
public static Matrix3D CreateRotationX(float sin, float cos)
|
||||
{
|
||||
return new global::PckStudio.Models.Matrix3D(1f, 0f, 0f, 0f, 0f, cos, -sin, 0f, 0f, sin, cos, 0f, 0f, 0f, 0f, 1f);
|
||||
return new Matrix3D(1f, 0f, 0f, 0f, 0f, cos, -sin, 0f, 0f, sin, cos, 0f, 0f, 0f, 0f, 1f);
|
||||
}
|
||||
|
||||
public static global::PckStudio.Models.Matrix3D CreateRotationY(float radians)
|
||||
public static Matrix3D CreateRotationY(float radians)
|
||||
{
|
||||
float num = (float)global::System.Math.Sin((double)radians);
|
||||
float num2 = (float)global::System.Math.Cos((double)radians);
|
||||
return new global::PckStudio.Models.Matrix3D(num2, 0f, num, 0f, 0f, 1f, 0f, 0f, -num, 0f, num2, 0f, 0f, 0f, 0f, 1f);
|
||||
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 global::PckStudio.Models.Matrix3D CreateRotationY(float sin, float cos)
|
||||
public static Matrix3D CreateRotationY(float sin, float cos)
|
||||
{
|
||||
return new global::PckStudio.Models.Matrix3D(cos, 0f, sin, 0f, 0f, 1f, 0f, 0f, -sin, 0f, cos, 0f, 0f, 0f, 0f, 1f);
|
||||
return new Matrix3D(cos, 0f, sin, 0f, 0f, 1f, 0f, 0f, -sin, 0f, cos, 0f, 0f, 0f, 0f, 1f);
|
||||
}
|
||||
|
||||
public static global::PckStudio.Models.Matrix3D CreateRotationZ(float radians)
|
||||
public static Matrix3D CreateRotationZ(float radians)
|
||||
{
|
||||
float num = (float)global::System.Math.Sin((double)radians);
|
||||
float num2 = (float)global::System.Math.Cos((double)radians);
|
||||
return new global::PckStudio.Models.Matrix3D(num2, -num, 0f, 0f, num, num2, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f);
|
||||
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 global::PckStudio.Models.Matrix3D CreateRotationZ(float sin, float cos)
|
||||
public static Matrix3D CreateRotationZ(float sin, float cos)
|
||||
{
|
||||
return new global::PckStudio.Models.Matrix3D(cos, -sin, 0f, 0f, sin, cos, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f);
|
||||
return new Matrix3D(cos, -sin, 0f, 0f, sin, cos, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f);
|
||||
}
|
||||
|
||||
public static global::PckStudio.Models.Matrix3D CreateTranslation(float x, float y, float z)
|
||||
public static Matrix3D CreateTranslation(float x, float y, float z)
|
||||
{
|
||||
return new global::PckStudio.Models.Matrix3D(1f, 0f, 0f, x, 0f, 1f, 0f, y, 0f, 0f, 1f, z, 0f, 0f, 0f, 1f);
|
||||
return new Matrix3D(1f, 0f, 0f, x, 0f, 1f, 0f, y, 0f, 0f, 1f, z, 0f, 0f, 0f, 1f);
|
||||
}
|
||||
|
||||
public static global::PckStudio.Models.Matrix3D CreateTranslation(global::PckStudio.Models.Point3D point)
|
||||
public static Matrix3D CreateTranslation(Point3D point)
|
||||
{
|
||||
return new global::PckStudio.Models.Matrix3D(1f, 0f, 0f, point.X, 0f, 1f, 0f, point.Y, 0f, 0f, 1f, point.Z, 0f, 0f, 0f, 1f);
|
||||
return new Matrix3D(1f, 0f, 0f, point.X, 0f, 1f, 0f, point.Y, 0f, 0f, 1f, point.Z, 0f, 0f, 0f, 1f);
|
||||
}
|
||||
|
||||
public static global::PckStudio.Models.Matrix3D CreateScale(float s)
|
||||
public static Matrix3D CreateScale(float s)
|
||||
{
|
||||
return new global::PckStudio.Models.Matrix3D(s, 0f, 0f, 0f, 0f, s, 0f, 0f, 0f, 0f, s, 0f, 0f, 0f, 0f, 1f);
|
||||
return new Matrix3D(s, 0f, 0f, 0f, 0f, s, 0f, 0f, 0f, 0f, s, 0f, 0f, 0f, 0f, 1f);
|
||||
}
|
||||
|
||||
public float Determinant
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.M11 * this.M22 * this.M33 * this.M44 + this.M21 * this.M32 * this.M43 * this.M14 + this.M31 * this.M42 * this.M13 * this.M24 + this.M41 * this.M12 * this.M23 * this.M34 - this.M14 * this.M23 * this.M32 * this.M41 - this.M24 * this.M33 * this.M42 * this.M11 - this.M34 * this.M43 * this.M12 * this.M21 - this.M44 * this.M13 * this.M22 * this.M31;
|
||||
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 global::PckStudio.Models.Matrix3D Identity
|
||||
public static Matrix3D Identity
|
||||
{
|
||||
get
|
||||
{
|
||||
return new global::PckStudio.Models.Matrix3D(1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f);
|
||||
return new Matrix3D(1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
public static global::PckStudio.Models.Matrix3D Transpose(global::PckStudio.Models.Matrix3D m)
|
||||
public static Matrix3D Transpose(Matrix3D m)
|
||||
{
|
||||
return new global::PckStudio.Models.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);
|
||||
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 global::PckStudio.Models.Matrix3D Invert(global::PckStudio.Models.Matrix3D m)
|
||||
public static Matrix3D Invert(Matrix3D m)
|
||||
{
|
||||
float determinant = m.Determinant;
|
||||
return new global::PckStudio.Models.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);
|
||||
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 global::PckStudio.Models.Matrix3D operator +(global::PckStudio.Models.Matrix3D a, global::PckStudio.Models.Matrix3D b)
|
||||
public static Matrix3D operator +(Matrix3D a, Matrix3D b)
|
||||
{
|
||||
return new global::PckStudio.Models.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);
|
||||
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 global::PckStudio.Models.Matrix3D operator -(global::PckStudio.Models.Matrix3D a, global::PckStudio.Models.Matrix3D b)
|
||||
public static Matrix3D operator -(Matrix3D a, Matrix3D b)
|
||||
{
|
||||
return new global::PckStudio.Models.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);
|
||||
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 global::PckStudio.Models.Matrix3D operator *(global::PckStudio.Models.Matrix3D a, global::PckStudio.Models.Matrix3D b)
|
||||
public static Matrix3D operator *(Matrix3D a, Matrix3D b)
|
||||
{
|
||||
return new global::PckStudio.Models.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);
|
||||
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 global::PckStudio.Models.Point3D operator *(global::PckStudio.Models.Matrix3D m, global::PckStudio.Models.Point3D p)
|
||||
public static Point3D operator *(Matrix3D m, Point3D p)
|
||||
{
|
||||
return new global::PckStudio.Models.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);
|
||||
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 global::PckStudio.Models.Matrix3D operator +(global::PckStudio.Models.Matrix3D m, float n)
|
||||
public static Matrix3D operator +(Matrix3D m, float n)
|
||||
{
|
||||
return new global::PckStudio.Models.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);
|
||||
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 global::PckStudio.Models.Matrix3D operator -(global::PckStudio.Models.Matrix3D m, float n)
|
||||
public static Matrix3D operator -(Matrix3D m, float n)
|
||||
{
|
||||
return new global::PckStudio.Models.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);
|
||||
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 global::PckStudio.Models.Matrix3D operator *(global::PckStudio.Models.Matrix3D m, float n)
|
||||
public static Matrix3D operator *(Matrix3D m, float n)
|
||||
{
|
||||
return new global::PckStudio.Models.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);
|
||||
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 global::PckStudio.Models.Matrix3D operator /(global::PckStudio.Models.Matrix3D m, float n)
|
||||
public static Matrix3D operator /(Matrix3D m, float n)
|
||||
{
|
||||
return new global::PckStudio.Models.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);
|
||||
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;
|
||||
|
||||
@@ -13,15 +13,11 @@ namespace PckStudio.Models
|
||||
{
|
||||
public partial class MinecraftModelView : Control
|
||||
{
|
||||
|
||||
|
||||
private const int IsometricFOV = 0x2E;
|
||||
|
||||
private string skinFilename;
|
||||
private const int IsometricFOV = 46;
|
||||
|
||||
internal float cameraZ = 31.4285717f;
|
||||
|
||||
private int fov = 0x46;
|
||||
private int Fov = 70;
|
||||
|
||||
private float scale = 1f;
|
||||
|
||||
@@ -31,100 +27,47 @@ namespace PckStudio.Models
|
||||
|
||||
private bool perspective = true;
|
||||
|
||||
private bool showUsername;
|
||||
|
||||
private string username = string.Empty;
|
||||
|
||||
private string skinUrlBase = "http://s3.amazonaws.com/MinecraftSkins/";
|
||||
|
||||
private string skinFileExt = ".png";
|
||||
|
||||
private float PiBy180 = 0.0174532924f;
|
||||
|
||||
private string info = "Minecraft Skin Viewer " + System.Windows.Forms.Application.ProductVersion + " Beta Prerelease";
|
||||
|
||||
|
||||
[System.ComponentModel.Browsable(true)]
|
||||
[System.ComponentModel.Category("Appearance")]
|
||||
public bool ShowUsername
|
||||
{
|
||||
get
|
||||
{
|
||||
return showUsername;
|
||||
}
|
||||
set
|
||||
{
|
||||
showUsername = value;
|
||||
base.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.Browsable(true)]
|
||||
[Browsable(true)]
|
||||
public event EventHandler SkinDowloadedx
|
||||
{
|
||||
add
|
||||
{
|
||||
System.EventHandler eventHandler = SkinDowloaded;
|
||||
System.EventHandler eventHandler2;
|
||||
EventHandler eventHandler = SkinDowloaded;
|
||||
EventHandler eventHandler2;
|
||||
do
|
||||
{
|
||||
eventHandler2 = eventHandler;
|
||||
System.EventHandler value2 = (System.EventHandler)System.Delegate.Combine(eventHandler2, value);
|
||||
eventHandler = System.Threading.Interlocked.CompareExchange<System.EventHandler>(ref SkinDowloaded, value2, eventHandler2);
|
||||
EventHandler value2 = (EventHandler)Delegate.Combine(eventHandler2, value);
|
||||
eventHandler = Interlocked.CompareExchange(ref SkinDowloaded, value2, eventHandler2);
|
||||
}
|
||||
while (eventHandler != eventHandler2);
|
||||
}
|
||||
remove
|
||||
{
|
||||
System.EventHandler eventHandler = SkinDowloaded;
|
||||
System.EventHandler eventHandler2;
|
||||
EventHandler eventHandler = SkinDowloaded;
|
||||
EventHandler eventHandler2;
|
||||
do
|
||||
{
|
||||
eventHandler2 = eventHandler;
|
||||
System.EventHandler value2 = (System.EventHandler)System.Delegate.Remove(eventHandler2, value);
|
||||
eventHandler = System.Threading.Interlocked.CompareExchange<System.EventHandler>(ref SkinDowloaded, value2, eventHandler2);
|
||||
EventHandler value2 = (EventHandler)Delegate.Remove(eventHandler2, value);
|
||||
eventHandler = Interlocked.CompareExchange(ref SkinDowloaded, value2, eventHandler2);
|
||||
}
|
||||
while (eventHandler != eventHandler2);
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.Browsable(true)]
|
||||
[System.ComponentModel.Category("Skin")]
|
||||
public string Username
|
||||
{
|
||||
get
|
||||
{
|
||||
return username;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.Length == 0)
|
||||
{
|
||||
username = string.Empty;
|
||||
return;
|
||||
}
|
||||
downloader.RunWorkerCompleted -= OnDownloaderRunWorkerCompleted;
|
||||
if (downloader.IsBusy)
|
||||
{
|
||||
downloader.CancelAsync();
|
||||
}
|
||||
downloader = new System.ComponentModel.BackgroundWorker();
|
||||
InitializeDownloader();
|
||||
username = value.Trim();
|
||||
downloader.RunWorkerAsync();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnBackColorChanged(System.EventArgs e)
|
||||
protected override void OnBackColorChanged(EventArgs e)
|
||||
{
|
||||
base.OnBackColorChanged(e);
|
||||
backgroundColor = BackColor;
|
||||
UpdateBackgroundBrush();
|
||||
base.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
[System.ComponentModel.Browsable(true)]
|
||||
[System.ComponentModel.Category("Appearance")]
|
||||
[Browsable(true)]
|
||||
[Category("Appearance")]
|
||||
public System.Drawing.Color BackGradientColor1
|
||||
{
|
||||
get
|
||||
@@ -135,12 +78,12 @@ namespace PckStudio.Models
|
||||
{
|
||||
backgroundGradientColor1 = value;
|
||||
UpdateBackgroundBrush();
|
||||
base.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.Browsable(true)]
|
||||
[System.ComponentModel.Category("Appearance")]
|
||||
[Browsable(true)]
|
||||
[Category("Appearance")]
|
||||
public System.Drawing.Color BackGradientColor2
|
||||
{
|
||||
get
|
||||
@@ -151,26 +94,12 @@ namespace PckStudio.Models
|
||||
{
|
||||
backgroundGradientColor2 = value;
|
||||
UpdateBackgroundBrush();
|
||||
base.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.Browsable(false)]
|
||||
[System.ComponentModel.Category("Appearance")]
|
||||
[System.Obsolete]
|
||||
public new System.Windows.Forms.ImageLayout BackgroundImageLayout
|
||||
{
|
||||
get
|
||||
{
|
||||
return System.Windows.Forms.ImageLayout.Tile;
|
||||
}
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.Browsable(true)]
|
||||
[System.ComponentModel.Category("Appearance")]
|
||||
[Browsable(true)]
|
||||
[Category("Appearance")]
|
||||
public new System.Drawing.Image BackgroundImage
|
||||
{
|
||||
get
|
||||
@@ -181,12 +110,12 @@ namespace PckStudio.Models
|
||||
{
|
||||
backgroundTexture = value;
|
||||
UpdateBackgroundBrush();
|
||||
base.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.Browsable(true)]
|
||||
[System.ComponentModel.Category("Appearance")]
|
||||
[Browsable(true)]
|
||||
[Category("Appearance")]
|
||||
public BackgroundTypes BackgroundType
|
||||
{
|
||||
get
|
||||
@@ -197,56 +126,52 @@ namespace PckStudio.Models
|
||||
{
|
||||
backgroundType = value;
|
||||
UpdateBackgroundBrush();
|
||||
base.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.Browsable(true)]
|
||||
[System.ComponentModel.Category("View")]
|
||||
[Browsable(true)]
|
||||
[Category("View")]
|
||||
public ProjectionTypes Projection
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!perspective)
|
||||
{
|
||||
return ProjectionTypes.Isometric;
|
||||
}
|
||||
return ProjectionTypes.Perspective;
|
||||
return perspective ? ProjectionTypes.Perspective : ProjectionTypes.Isometric;
|
||||
}
|
||||
set
|
||||
{
|
||||
perspective = (value == ProjectionTypes.Perspective);
|
||||
perspective = value == ProjectionTypes.Perspective;
|
||||
SetupProjection();
|
||||
foreach (Object3D object3D in object3DList)
|
||||
{
|
||||
object3D.Update();
|
||||
}
|
||||
base.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.Browsable(true)]
|
||||
[System.ComponentModel.Category("View")]
|
||||
[Browsable(true)]
|
||||
[Category("View")]
|
||||
public int FOV
|
||||
{
|
||||
get
|
||||
{
|
||||
return fov;
|
||||
return Fov;
|
||||
}
|
||||
set
|
||||
{
|
||||
fov = value;
|
||||
Fov = value;
|
||||
SetupProjection();
|
||||
foreach (Object3D object3D in object3DList)
|
||||
{
|
||||
object3D.Update();
|
||||
}
|
||||
base.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.Browsable(true)]
|
||||
[System.ComponentModel.Category("View")]
|
||||
[Browsable(true)]
|
||||
[Category("View")]
|
||||
public int DegreesX
|
||||
{
|
||||
get
|
||||
@@ -255,18 +180,18 @@ namespace PckStudio.Models
|
||||
}
|
||||
set
|
||||
{
|
||||
RotationX = (float)value;
|
||||
RotationX = value;
|
||||
Matrix3D globalTransformation = Matrix3D.CreateRotationX(RotationX * PiBy180) * Matrix3D.CreateRotationY(RotationY * PiBy180);
|
||||
foreach (Object3D object3D in object3DList)
|
||||
{
|
||||
object3D.GlobalTransformation = globalTransformation;
|
||||
}
|
||||
base.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.Browsable(true)]
|
||||
[System.ComponentModel.Category("View")]
|
||||
[Browsable(true)]
|
||||
[Category("View")]
|
||||
public int DegreesY
|
||||
{
|
||||
get
|
||||
@@ -275,17 +200,17 @@ namespace PckStudio.Models
|
||||
}
|
||||
set
|
||||
{
|
||||
RotationY = (float)value;
|
||||
RotationY = value;
|
||||
Matrix3D globalTransformation = Matrix3D.CreateRotationX(RotationX * PiBy180) * Matrix3D.CreateRotationY(RotationY * PiBy180);
|
||||
foreach (Object3D object3D in object3DList)
|
||||
{
|
||||
object3D.GlobalTransformation = globalTransformation;
|
||||
}
|
||||
base.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public Models.ModelBase Model
|
||||
public ModelBase Model
|
||||
{
|
||||
set
|
||||
{
|
||||
@@ -296,19 +221,11 @@ namespace PckStudio.Models
|
||||
{
|
||||
object3D.GlobalTransformation = globalTransformation;
|
||||
}
|
||||
base.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void InitializeDownloader()
|
||||
{
|
||||
downloader.WorkerSupportsCancellation = true;
|
||||
downloader.DoWork += OnDownloaderDoWork;
|
||||
downloader.RunWorkerCompleted += OnDownloaderRunWorkerCompleted;
|
||||
}
|
||||
|
||||
protected virtual void OnSkinDownloaded(System.EventArgs args)
|
||||
protected virtual void OnSkinDownloaded(EventArgs args)
|
||||
{
|
||||
if (SkinDowloaded != null)
|
||||
{
|
||||
@@ -316,32 +233,6 @@ namespace PckStudio.Models
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDownloaderRunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
RenderUsernameImage();
|
||||
OnSkinDownloaded(System.EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void OnDownloaderDoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
|
||||
{
|
||||
System.Net.WebClient webClient = new System.Net.WebClient();
|
||||
try
|
||||
{
|
||||
byte[] buffer = webClient.DownloadData(skinUrlBase + username + skinFileExt);
|
||||
if (webSkin != null)
|
||||
{
|
||||
webSkin.Dispose();
|
||||
}
|
||||
webSkin = System.Drawing.Image.FromStream(new System.IO.MemoryStream(buffer));
|
||||
}
|
||||
catch
|
||||
{
|
||||
webSkin = null;
|
||||
username = string.Empty;
|
||||
usernameImage = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Clear()
|
||||
{
|
||||
texelList.Clear();
|
||||
@@ -350,21 +241,17 @@ namespace PckStudio.Models
|
||||
rotatingObject3D = null;
|
||||
}
|
||||
|
||||
protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
|
||||
protected override void OnPaintBackground(PaintEventArgs pevent)
|
||||
{
|
||||
base.OnPaintBackground(pevent);
|
||||
System.Drawing.Graphics graphics = pevent.Graphics;
|
||||
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
|
||||
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighSpeed;
|
||||
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
|
||||
graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
|
||||
graphics.FillRectangle(backgroundBrush, base.ClientRectangle);
|
||||
graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
|
||||
if (showUsername && usernameImage != null)
|
||||
{
|
||||
graphics.DrawImage(usernameImage, base.Width / 2 - usernameImage.Width / 2, base.Height - 0x20);
|
||||
}
|
||||
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;
|
||||
if (versionImage == null)
|
||||
{
|
||||
versionImage = RenderVersionText();
|
||||
@@ -372,17 +259,17 @@ namespace PckStudio.Models
|
||||
graphics.DrawImage(versionImage, 3, 3);
|
||||
}
|
||||
|
||||
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pe)
|
||||
protected override void OnPaint(PaintEventArgs pe)
|
||||
{
|
||||
texelList.Sort(texelComparer);
|
||||
System.Drawing.Graphics graphics = pe.Graphics;
|
||||
graphics.TranslateTransform((float)(base.Width / 2), (float)(base.Height / 2));
|
||||
graphics.TranslateTransform(Width / 2, Height / 2);
|
||||
graphics.ScaleTransform(scale, -scale);
|
||||
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
|
||||
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighSpeed;
|
||||
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
|
||||
graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
|
||||
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);
|
||||
@@ -391,23 +278,23 @@ namespace PckStudio.Models
|
||||
|
||||
public System.Drawing.Image RenderToImage(System.Drawing.Size size, System.Drawing.RectangleF crop)
|
||||
{
|
||||
if ((float)(size.Width / size.Height) != crop.Width / crop.Height)
|
||||
if (size.Width / size.Height != crop.Width / crop.Height)
|
||||
{
|
||||
throw new System.ArgumentException("Aspect ratio is ambiguous");
|
||||
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)((float)size.Width / crop.Width), (int)((float)size.Height / crop.Height));
|
||||
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 * (float)size2.Width, -crop.Top * (float)size2.Height);
|
||||
graphics.TranslateTransform((float)(size2.Width / 2), (float)(size2.Height / 2));
|
||||
float num = (float)System.Math.Min(size2.Width, size2.Height) * 0.01f / (float)System.Math.Tan((double)(perspective ? fov : 0x2E) * 3.1415926535897931 / 360.0);
|
||||
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 = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
|
||||
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighSpeed;
|
||||
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
|
||||
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++)
|
||||
{
|
||||
@@ -420,16 +307,16 @@ namespace PckStudio.Models
|
||||
private System.Drawing.Image RenderText(string text)
|
||||
{
|
||||
int num = 0;
|
||||
using (System.Drawing.Graphics graphics = base.CreateGraphics())
|
||||
using (System.Drawing.Graphics graphics = CreateGraphics())
|
||||
{
|
||||
num = (int)graphics.MeasureString(text, Font).Width;
|
||||
}
|
||||
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(num + 2, 0x12);
|
||||
using (System.Drawing.Graphics graphics2 = System.Drawing.Graphics.FromImage(bitmap))
|
||||
{
|
||||
using (System.Drawing.Brush brush = new System.Drawing.SolidBrush(MinecraftModelView.textShadowColor))
|
||||
using (System.Drawing.Brush brush = new System.Drawing.SolidBrush(textShadowColor))
|
||||
{
|
||||
graphics2.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
|
||||
graphics2.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
|
||||
graphics2.DrawString(text, Font, brush, 2f, 2f);
|
||||
graphics2.DrawString(text, Font, System.Drawing.Brushes.White, 0f, 0f);
|
||||
}
|
||||
@@ -440,21 +327,13 @@ namespace PckStudio.Models
|
||||
private System.Drawing.Image RenderVersionText()
|
||||
{
|
||||
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(0x154, 0x12);
|
||||
System.Version version = new System.Version(System.Windows.Forms.Application.ProductVersion);
|
||||
string s = string.Concat(new object[]
|
||||
{
|
||||
System.Windows.Forms.Application.ProductName,
|
||||
" ",
|
||||
version.Major,
|
||||
".",
|
||||
version.Minor,
|
||||
(version.Build != 0) ? ("." + version.Build) : ""
|
||||
});
|
||||
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 = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
|
||||
graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
|
||||
graphics.DrawString(s, Font, brush, 1f, 1f);
|
||||
graphics.DrawString(s, Font, System.Drawing.Brushes.White, 0f, 0f);
|
||||
}
|
||||
@@ -462,14 +341,6 @@ namespace PckStudio.Models
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private void RenderUsernameImage()
|
||||
{
|
||||
if (username != null && username.Length > 0)
|
||||
{
|
||||
usernameImage = RenderText(username);
|
||||
}
|
||||
}
|
||||
|
||||
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)));
|
||||
@@ -485,16 +356,16 @@ namespace PckStudio.Models
|
||||
{
|
||||
return new System.Drawing.SolidBrush(backgroundColor);
|
||||
}
|
||||
return new System.Drawing.Drawing2D.LinearGradientBrush(new System.Drawing.Point(0, 0), new System.Drawing.Point(0, System.Math.Max(1, size.Height)), backgroundGradientColor1, backgroundGradientColor2);
|
||||
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 / (float)fov;
|
||||
scale = (float)System.Math.Min(base.Width, base.Height) * 0.01f / (float)System.Math.Tan((double)(perspective ? fov : 0x2E) * 3.1415926535897931 / 360.0);
|
||||
cameraZ = 2400f / Fov;
|
||||
scale = Math.Min(Width, Height) * 0.01f / (float)Math.Tan((perspective ? Fov : IsometricFOV) * Math.PI / 360.0);
|
||||
}
|
||||
|
||||
protected override void OnResize(System.EventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
SetupProjection();
|
||||
UpdateBackgroundBrush();
|
||||
@@ -518,10 +389,10 @@ namespace PckStudio.Models
|
||||
texelList.Add(texel);
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
System.Drawing.PointF location = new System.Drawing.PointF(((float)e.X - (float)base.Width * 0.5f) / scale, -((float)e.Y - (float)base.Height * 0.5f) / scale);
|
||||
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;
|
||||
@@ -539,38 +410,38 @@ namespace PckStudio.Models
|
||||
rotatingObject3D = item;
|
||||
}
|
||||
mouseLastLocation = e.Location;
|
||||
base.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
rotatingObject3D = null;
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
if (e.Button != System.Windows.Forms.MouseButtons.Left)
|
||||
if (e.Button != MouseButtons.Left)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (rotatingObject3D != null)
|
||||
{
|
||||
rotatingObject3D.RotateByMouse((float)(e.X - mouseLastLocation.X) * 400f / (float)base.Height, (float)(e.Y - mouseLastLocation.Y) * 400f / (float)base.Height);
|
||||
rotatingObject3D.RotateByMouse((e.X - mouseLastLocation.X) * 400f / Height, (e.Y - mouseLastLocation.Y) * 400f / Height);
|
||||
mouseLastLocation = e.Location;
|
||||
base.Invalidate();
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
RotationY += (float)(e.X - mouseLastLocation.X) * 400f / (float)base.Height;
|
||||
RotationX += (float)(e.Y - mouseLastLocation.Y) * 400f / (float)base.Height;
|
||||
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;
|
||||
}
|
||||
base.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public void AddStatic(Object3D object3D)
|
||||
@@ -585,13 +456,8 @@ namespace PckStudio.Models
|
||||
|
||||
public void AddDynamic(Object3D object3D)
|
||||
{
|
||||
object3D.Viewport = this;
|
||||
object3DList.Add(object3D);
|
||||
AddStatic(object3D);
|
||||
dynamicObject3DtList.Add(object3D);
|
||||
foreach (Object3D object3D2 in object3DList)
|
||||
{
|
||||
object3D2.Update();
|
||||
}
|
||||
}
|
||||
|
||||
internal System.Drawing.PointF Point3DTo2D(Point3D point3D)
|
||||
@@ -612,115 +478,16 @@ namespace PckStudio.Models
|
||||
return -point3D.Z;
|
||||
}
|
||||
|
||||
private unsafe System.Drawing.Image CorrectSkin(System.Drawing.Image skin)
|
||||
public MinecraftModelView()
|
||||
{
|
||||
if (skin == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(skin);
|
||||
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height);
|
||||
System.Drawing.Imaging.BitmapData bitmapData = bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
for (int i = 0; i < 0x10; i++)
|
||||
{
|
||||
byte* ptr = (byte*)((void*)bitmapData.Scan0) + (int)i * (int)bitmapData.Stride;
|
||||
for (int j = 3; j < 0x80; j += 4)
|
||||
{
|
||||
ptr[j] = byte.MaxValue;
|
||||
}
|
||||
}
|
||||
for (int k = 0x10; k < 0x20; k++)
|
||||
{
|
||||
byte* ptr2 = (byte*)((void*)bitmapData.Scan0) + (int)k * (int)bitmapData.Stride;
|
||||
for (int l = 3; l < 0x100; l += 4)
|
||||
{
|
||||
ptr2[l] = byte.MaxValue;
|
||||
}
|
||||
}
|
||||
bool flag = false;
|
||||
for (int m = 0; m < 8; m++)
|
||||
{
|
||||
byte* ptr3 = (byte*)((void*)bitmapData.Scan0) + (int)m * (int)bitmapData.Stride;
|
||||
for (int n = 0xA3; n < 0xE0; n += 4)
|
||||
{
|
||||
if (ptr3[n] != 0xFF)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int num = 8; num < 0x10; num++)
|
||||
{
|
||||
byte* ptr4 = (byte*)((void*)bitmapData.Scan0) + (int)num * (int)bitmapData.Stride;
|
||||
for (int num2 = 0x83; num2 < 0x100; num2 += 4)
|
||||
{
|
||||
if (ptr4[num2] != 0xFF)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
for (int num3 = 0; num3 < 8; num3++)
|
||||
{
|
||||
byte* ptr5 = (byte*)((void*)bitmapData.Scan0) + (int)num3 * (int)bitmapData.Stride;
|
||||
for (int num4 = 0xA3; num4 < 0xE0; num4++)
|
||||
{
|
||||
ptr5[num4] = 0;
|
||||
}
|
||||
}
|
||||
for (int num5 = 8; num5 < 0x10; num5++)
|
||||
{
|
||||
byte* ptr6 = (byte*)((void*)bitmapData.Scan0) + (int)num5 * (int)bitmapData.Stride;
|
||||
for (int num6 = 0x83; num6 < 0x100; num6++)
|
||||
{
|
||||
ptr6[num6] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
bitmap.UnlockBits(bitmapData);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
internal void UpdateImage()
|
||||
{
|
||||
SetSkinFromFile(skinFilename);
|
||||
}
|
||||
|
||||
internal bool SetSkinFromFile(string filename)
|
||||
{
|
||||
skinFilename = filename;
|
||||
bool flag = true;
|
||||
using (System.IO.FileStream fileStream = System.IO.File.OpenRead(filename))
|
||||
{
|
||||
System.Drawing.Image image = System.Drawing.Image.FromStream(fileStream);
|
||||
if (image.Width != 0x40 || image.Height != 0x20)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("Image '" + System.IO.Path.GetFileName(filename) + "' is not Minecraft skin.", "Minecraft Skin Viewer", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
usernameImage = null;
|
||||
username = string.Empty;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public MinecraftModelView()
|
||||
{
|
||||
base.SetStyle(System.Windows.Forms.ControlStyles.ResizeRedraw | System.Windows.Forms.ControlStyles.AllPaintingInWmPaint | System.Windows.Forms.ControlStyles.OptimizedDoubleBuffer, true);
|
||||
SetStyle(ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
|
||||
InitializeComponent();
|
||||
texelComparer = new TexelComparer();
|
||||
}
|
||||
|
||||
public MinecraftModelView(IContainer container)
|
||||
public MinecraftModelView(IContainer container) : this()
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace PckStudio.Models
|
||||
{
|
||||
public abstract class Object3D
|
||||
{
|
||||
public abstract global::System.Drawing.Image Image { set; }
|
||||
public abstract Image Image { set; }
|
||||
|
||||
public float Angle1
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.angle1;
|
||||
return angle1;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.angle1 = value;
|
||||
this.UpdateRotation();
|
||||
angle1 = value;
|
||||
OnUpdateRotation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +24,12 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.angle2;
|
||||
return angle2;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.angle2 = value;
|
||||
this.UpdateRotation();
|
||||
angle2 = value;
|
||||
OnUpdateRotation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +37,11 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.minAngle1;
|
||||
return minAngle1;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.minAngle1 = value;
|
||||
minAngle1 = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,11 +49,11 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.minAngle2;
|
||||
return minAngle2;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.minAngle2 = value;
|
||||
minAngle2 = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +61,11 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.maxAngle1;
|
||||
return maxAngle1;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.maxAngle1 = value;
|
||||
maxAngle1 = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,11 +73,11 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.maxAngle2;
|
||||
return maxAngle2;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.maxAngle2 = value;
|
||||
maxAngle2 = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,12 +85,12 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.maxAngle1 - this.minAngle1;
|
||||
return maxAngle1 - minAngle1;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.minAngle1 = this.angle1 - value / 2f;
|
||||
this.maxAngle1 = this.angle1 + value / 2f;
|
||||
minAngle1 = angle1 - value / 2f;
|
||||
maxAngle1 = angle1 + value / 2f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,12 +98,12 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.maxAngle2 - this.minAngle2;
|
||||
return maxAngle2 - minAngle2;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.minAngle2 = this.angle2 - value / 2f;
|
||||
this.maxAngle2 = this.angle2 + value / 2f;
|
||||
minAngle2 = angle2 - value / 2f;
|
||||
maxAngle2 = angle2 + value / 2f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,11 +111,11 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.minAngle1 / 0.0174532924f;
|
||||
return minAngle1 / PIby180;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.minAngle1 = value * 0.0174532924f;
|
||||
minAngle1 = value * PIby180;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,11 +123,11 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.minAngle2 / 0.0174532924f;
|
||||
return minAngle2 / PIby180;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.minAngle2 = value * 0.0174532924f;
|
||||
minAngle2 = value * PIby180;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,11 +135,11 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.maxAngle1 / 0.0174532924f;
|
||||
return maxAngle1 / PIby180;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.maxAngle1 = value * 0.0174532924f;
|
||||
maxAngle1 = value * PIby180;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,11 +147,11 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.maxAngle2 / 0.0174532924f;
|
||||
return maxAngle2 / PIby180;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.maxAngle2 = value * 0.0174532924f;
|
||||
maxAngle2 = value * PIby180;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,11 +159,11 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.AngleRange1 / 0.0174532924f;
|
||||
return AngleRange1 / PIby180;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.AngleRange1 = value * 0.0174532924f;
|
||||
AngleRange1 = value * PIby180;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,11 +171,11 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.AngleRange2 / 0.0174532924f;
|
||||
return AngleRange2 / PIby180;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.AngleRange2 = value * 0.0174532924f;
|
||||
AngleRange2 = value * PIby180;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,116 +183,116 @@ namespace PckStudio.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.scaleTransformation.M11;
|
||||
return scaleTransformation.M11;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.scaleTransformation = global::PckStudio.Models.Matrix3D.CreateScale(value);
|
||||
this.localTransformation = this.positionTranslation * this.localRotation * this.originTranslation * this.scaleTransformation;
|
||||
scaleTransformation = Matrix3D.CreateScale(value);
|
||||
UpdateRotation();
|
||||
}
|
||||
}
|
||||
|
||||
public global::PckStudio.Models.RotationOrders RotationOrder
|
||||
public RotationOrders RotationOrder
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.order;
|
||||
return order;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.order = value;
|
||||
switch (this.order)
|
||||
order = value;
|
||||
switch (order)
|
||||
{
|
||||
case global::PckStudio.Models.RotationOrders.XY:
|
||||
this.Rotate = new global::PckStudio.Models.Object3D.RotateMethod(this.RotateXY);
|
||||
this.UpdateRotation = new global::PckStudio.Models.Object3D.UpdateRotationMethod(this.UpdateRotationXY);
|
||||
return;
|
||||
case global::PckStudio.Models.RotationOrders.YX:
|
||||
this.Rotate = new global::PckStudio.Models.Object3D.RotateMethod(this.RotateYX);
|
||||
this.UpdateRotation = new global::PckStudio.Models.Object3D.UpdateRotationMethod(this.UpdateRotationYX);
|
||||
return;
|
||||
case global::PckStudio.Models.RotationOrders.XZ:
|
||||
this.Rotate = new global::PckStudio.Models.Object3D.RotateMethod(this.RotateXZ);
|
||||
this.UpdateRotation = new global::PckStudio.Models.Object3D.UpdateRotationMethod(this.UpdateRotationXZ);
|
||||
return;
|
||||
case global::PckStudio.Models.RotationOrders.ZX:
|
||||
this.Rotate = new global::PckStudio.Models.Object3D.RotateMethod(this.RotateZX);
|
||||
this.UpdateRotation = new global::PckStudio.Models.Object3D.UpdateRotationMethod(this.UpdateRotationZX);
|
||||
return;
|
||||
case global::PckStudio.Models.RotationOrders.YZ:
|
||||
this.Rotate = new global::PckStudio.Models.Object3D.RotateMethod(this.RotateYZ);
|
||||
this.UpdateRotation = new global::PckStudio.Models.Object3D.UpdateRotationMethod(this.UpdateRotationYZ);
|
||||
return;
|
||||
case global::PckStudio.Models.RotationOrders.ZY:
|
||||
this.Rotate = new global::PckStudio.Models.Object3D.RotateMethod(this.RotateZY);
|
||||
this.UpdateRotation = new global::PckStudio.Models.Object3D.UpdateRotationMethod(this.UpdateRotationZY);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
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 global::PckStudio.Models.MinecraftModelView Viewport
|
||||
internal virtual MinecraftModelView Viewport
|
||||
{
|
||||
set
|
||||
{
|
||||
this.viewport = value;
|
||||
viewport = value;
|
||||
}
|
||||
}
|
||||
|
||||
public global::PckStudio.Models.Point3D Origin
|
||||
public Point3D Origin
|
||||
{
|
||||
get
|
||||
{
|
||||
return new global::PckStudio.Models.Point3D(-this.originTranslation.M14, -this.originTranslation.M24, -this.originTranslation.M34);
|
||||
return new Point3D(-originTranslation.M14, -originTranslation.M24, -originTranslation.M34);
|
||||
}
|
||||
set
|
||||
{
|
||||
this.originTranslation = global::PckStudio.Models.Matrix3D.CreateTranslation(-value.X, -value.Y, -value.Z);
|
||||
this.localTransformation = this.positionTranslation * this.localRotation * this.originTranslation * this.scaleTransformation;
|
||||
originTranslation = Matrix3D.CreateTranslation(-value.X, -value.Y, -value.Z);
|
||||
UpdateRotation();
|
||||
}
|
||||
}
|
||||
|
||||
public global::PckStudio.Models.Point3D Position
|
||||
public Point3D Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return new global::PckStudio.Models.Point3D(this.positionTranslation.M14, this.positionTranslation.M24, this.positionTranslation.M34);
|
||||
return new Point3D(positionTranslation.M14, positionTranslation.M24, positionTranslation.M34);
|
||||
}
|
||||
set
|
||||
{
|
||||
this.positionTranslation = global::PckStudio.Models.Matrix3D.CreateTranslation(value);
|
||||
this.localTransformation = this.positionTranslation * this.localRotation * this.originTranslation * this.scaleTransformation;
|
||||
this.Update();
|
||||
positionTranslation = Matrix3D.CreateTranslation(value);
|
||||
UpdateRotation();
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
internal abstract void Update();
|
||||
|
||||
public global::PckStudio.Models.Matrix3D GlobalTransformation
|
||||
public Matrix3D GlobalTransformation
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.globalTransformation;
|
||||
return globalTransformation;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.globalTransformation = value;
|
||||
this.Update();
|
||||
globalTransformation = value;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
public global::PckStudio.Models.Matrix3D LocalTransformation
|
||||
public Matrix3D LocalTransformation
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.localTransformation;
|
||||
return localTransformation;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.localTransformation = value;
|
||||
this.Update();
|
||||
localTransformation = value;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,165 +300,162 @@ namespace PckStudio.Models
|
||||
{
|
||||
this.angle1 = angle1;
|
||||
this.angle2 = angle2;
|
||||
this.UpdateRotation();
|
||||
OnUpdateRotation();
|
||||
}
|
||||
|
||||
public void RotateByMouse(float deltaX, float deltaY)
|
||||
{
|
||||
if (this.Rotate != null)
|
||||
if (Rotate != null)
|
||||
{
|
||||
this.Rotate(deltaX, deltaY);
|
||||
this.Update();
|
||||
Rotate(deltaX, deltaY);
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
private void CorrectAngles()
|
||||
{
|
||||
if (this.angle1 > this.maxAngle1)
|
||||
if (angle1 > maxAngle1)
|
||||
{
|
||||
this.angle1 = this.maxAngle1;
|
||||
angle1 = maxAngle1;
|
||||
}
|
||||
else if (this.angle1 < this.minAngle1)
|
||||
else if (angle1 < minAngle1)
|
||||
{
|
||||
this.angle1 = this.minAngle1;
|
||||
angle1 = minAngle1;
|
||||
}
|
||||
if (this.angle2 > this.maxAngle2)
|
||||
if (angle2 > maxAngle2)
|
||||
{
|
||||
this.angle2 = this.maxAngle2;
|
||||
angle2 = maxAngle2;
|
||||
return;
|
||||
}
|
||||
if (this.angle2 < this.minAngle2)
|
||||
if (angle2 < minAngle2)
|
||||
{
|
||||
this.angle2 = this.minAngle2;
|
||||
angle2 = minAngle2;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract float HitTest(global::System.Drawing.PointF location);
|
||||
public abstract float HitTest(PointF location);
|
||||
|
||||
private void RotateXY(float delta1, float delta2)
|
||||
{
|
||||
this.angle1 += delta1 * 0.0174532924f;
|
||||
this.angle2 += delta2 * 0.0174532924f * (float)global::System.Math.Cos((double)(this.viewport.RotationY * 0.0174532924f));
|
||||
this.UpdateRotationXY();
|
||||
angle1 += delta1 * PIby180;
|
||||
angle2 += delta2 * PIby180 * (float)Math.Cos((double)(viewport.RotationY * PIby180));
|
||||
UpdateRotationXY();
|
||||
}
|
||||
|
||||
private void RotateYX(float delta1, float delta2)
|
||||
{
|
||||
this.angle1 += delta1 * 0.0174532924f;
|
||||
this.angle2 += delta2 * 0.0174532924f * (float)global::System.Math.Cos((double)this.viewport.RotationY * 3.1415926535897931 / 180.0);
|
||||
this.UpdateRotationYX();
|
||||
angle1 += delta1 * PIby180;
|
||||
angle2 += delta2 * PIby180 * (float)Math.Cos(viewport.RotationY * 3.1415926535897931 / 180.0);
|
||||
UpdateRotationYX();
|
||||
}
|
||||
|
||||
private void RotateXZ(float delta1, float delta2)
|
||||
{
|
||||
this.angle1 += delta1 * 0.0174532924f * (float)global::System.Math.Cos((double)(this.viewport.RotationY * 0.0174532924f)) + delta2 * 0.0174532924f * (float)global::System.Math.Sin((double)(this.viewport.RotationY * 0.0174532924f));
|
||||
this.angle2 += delta2 * 0.0174532924f * (float)global::System.Math.Cos((double)(this.viewport.RotationY * 0.0174532924f)) - delta1 * 0.0174532924f * (float)global::System.Math.Sin((double)(this.viewport.RotationY * 0.0174532924f));
|
||||
this.UpdateRotationXZ();
|
||||
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)
|
||||
{
|
||||
this.angle1 += delta1 * 0.0174532924f * (float)global::System.Math.Cos((double)(this.viewport.RotationY * 0.0174532924f)) + delta2 * 0.0174532924f * (float)global::System.Math.Sin((double)(this.viewport.RotationY * 0.0174532924f));
|
||||
this.angle2 += delta2 * 0.0174532924f * (float)global::System.Math.Cos((double)(this.viewport.RotationY * 0.0174532924f)) - delta1 * 0.0174532924f * (float)global::System.Math.Sin((double)(this.viewport.RotationY * 0.0174532924f));
|
||||
this.UpdateRotationZX();
|
||||
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)
|
||||
{
|
||||
this.angle1 -= delta2 * 0.0174532924f;
|
||||
this.angle2 += delta1 * 0.0174532924f;
|
||||
this.UpdateRotationZY();
|
||||
angle1 -= delta2 * PIby180;
|
||||
angle2 += delta1 * PIby180;
|
||||
UpdateRotationZY();
|
||||
}
|
||||
|
||||
private void RotateYZ(float delta1, float delta2)
|
||||
{
|
||||
this.angle1 += delta1 * 0.0174532924f;
|
||||
this.angle2 += delta2 * 0.0174532924f * (float)global::System.Math.Sin((double)(this.viewport.RotationY * 0.0174532924f));
|
||||
this.UpdateRotationYZ();
|
||||
angle1 += delta1 * PIby180;
|
||||
angle2 += delta2 * PIby180 * (float)Math.Sin((double)(viewport.RotationY * PIby180));
|
||||
UpdateRotationYZ();
|
||||
}
|
||||
|
||||
private void UpdateRotationXY()
|
||||
{
|
||||
this.CorrectAngles();
|
||||
this.localRotation = global::PckStudio.Models.Matrix3D.CreateRotationY(this.angle1) * global::PckStudio.Models.Matrix3D.CreateRotationX(this.angle2);
|
||||
this.localTransformation = this.positionTranslation * this.localRotation * this.originTranslation * this.scaleTransformation;
|
||||
CorrectAngles();
|
||||
localRotation = Matrix3D.CreateRotationY(angle1) * Matrix3D.CreateRotationX(angle2);
|
||||
UpdateRotation();
|
||||
}
|
||||
|
||||
private void UpdateRotationYX()
|
||||
{
|
||||
this.CorrectAngles();
|
||||
this.localRotation = global::PckStudio.Models.Matrix3D.CreateRotationX(this.angle2) * global::PckStudio.Models.Matrix3D.CreateRotationY(this.angle1);
|
||||
this.localTransformation = this.positionTranslation * this.localRotation * this.originTranslation * this.scaleTransformation;
|
||||
CorrectAngles();
|
||||
localRotation = Matrix3D.CreateRotationX(angle2) * Matrix3D.CreateRotationY(angle1);
|
||||
UpdateRotation();
|
||||
}
|
||||
|
||||
private void UpdateRotationXZ()
|
||||
{
|
||||
this.CorrectAngles();
|
||||
this.localRotation = global::PckStudio.Models.Matrix3D.CreateRotationZ(this.angle1) * global::PckStudio.Models.Matrix3D.CreateRotationX(this.angle2);
|
||||
this.localTransformation = this.positionTranslation * this.localRotation * this.originTranslation * this.scaleTransformation;
|
||||
CorrectAngles();
|
||||
localRotation = Matrix3D.CreateRotationZ(angle1) * Matrix3D.CreateRotationX(angle2);
|
||||
UpdateRotation();
|
||||
}
|
||||
|
||||
private void UpdateRotationZX()
|
||||
{
|
||||
this.CorrectAngles();
|
||||
this.localRotation = global::PckStudio.Models.Matrix3D.CreateRotationX(this.angle2) * global::PckStudio.Models.Matrix3D.CreateRotationZ(this.angle1);
|
||||
this.localTransformation = this.positionTranslation * this.localRotation * this.originTranslation * this.scaleTransformation;
|
||||
CorrectAngles();
|
||||
localRotation = Matrix3D.CreateRotationX(angle2) * Matrix3D.CreateRotationZ(angle1);
|
||||
UpdateRotation();
|
||||
}
|
||||
|
||||
private void UpdateRotationZY()
|
||||
{
|
||||
this.CorrectAngles();
|
||||
this.localRotation = global::PckStudio.Models.Matrix3D.CreateRotationY(this.angle2) * global::PckStudio.Models.Matrix3D.CreateRotationZ(this.angle1);
|
||||
this.localTransformation = this.positionTranslation * this.localRotation * this.originTranslation * this.scaleTransformation;
|
||||
CorrectAngles();
|
||||
localRotation = Matrix3D.CreateRotationY(angle2) * Matrix3D.CreateRotationZ(angle1);
|
||||
UpdateRotation();
|
||||
}
|
||||
|
||||
private void UpdateRotationYZ()
|
||||
{
|
||||
this.CorrectAngles();
|
||||
this.localRotation = global::PckStudio.Models.Matrix3D.CreateRotationZ(this.angle2) * global::PckStudio.Models.Matrix3D.CreateRotationY(this.angle1);
|
||||
this.localTransformation = this.positionTranslation * this.localRotation * this.originTranslation * this.scaleTransformation;
|
||||
CorrectAngles();
|
||||
localRotation = Matrix3D.CreateRotationZ(angle2) * Matrix3D.CreateRotationY(angle1);
|
||||
UpdateRotation();
|
||||
}
|
||||
|
||||
protected Object3D()
|
||||
private void UpdateRotation()
|
||||
{
|
||||
}
|
||||
localTransformation = positionTranslation * localRotation * originTranslation * scaleTransformation;
|
||||
}
|
||||
|
||||
public const float PIby180 = 0.0174532924f;
|
||||
|
||||
protected global::PckStudio.Models.Matrix3D originTranslation = global::PckStudio.Models.Matrix3D.Identity;
|
||||
protected Matrix3D originTranslation = Matrix3D.Identity;
|
||||
|
||||
protected global::PckStudio.Models.Matrix3D positionTranslation = global::PckStudio.Models.Matrix3D.Identity;
|
||||
protected Matrix3D positionTranslation = Matrix3D.Identity;
|
||||
|
||||
protected global::PckStudio.Models.Matrix3D scaleTransformation = global::PckStudio.Models.Matrix3D.Identity;
|
||||
protected Matrix3D scaleTransformation = Matrix3D.Identity;
|
||||
|
||||
protected global::PckStudio.Models.Matrix3D localRotation = global::PckStudio.Models.Matrix3D.Identity;
|
||||
protected Matrix3D localRotation = Matrix3D.Identity;
|
||||
|
||||
protected global::PckStudio.Models.Matrix3D localTransformation = global::PckStudio.Models.Matrix3D.Identity;
|
||||
protected Matrix3D localTransformation = Matrix3D.Identity;
|
||||
|
||||
protected global::PckStudio.Models.Matrix3D globalTransformation = global::PckStudio.Models.Matrix3D.Identity;
|
||||
protected Matrix3D globalTransformation = Matrix3D.Identity;
|
||||
|
||||
private float angle1;
|
||||
|
||||
private float angle2;
|
||||
|
||||
private float maxAngle1 = 3.14159274f;
|
||||
private float maxAngle1 = (float)Math.PI;
|
||||
private float minAngle1 = (float)-Math.PI;
|
||||
|
||||
private float minAngle1 = -3.14159274f;
|
||||
private float maxAngle2 = (float)Math.PI;
|
||||
private float minAngle2 = (float)-Math.PI;
|
||||
|
||||
private float maxAngle2 = 3.14159274f;
|
||||
private RotationOrders order;
|
||||
|
||||
private float minAngle2 = -3.14159274f;
|
||||
protected MinecraftModelView viewport;
|
||||
|
||||
private global::PckStudio.Models.RotationOrders order;
|
||||
private RotateMethod Rotate;
|
||||
|
||||
protected global::PckStudio.Models.MinecraftModelView viewport;
|
||||
|
||||
private global::PckStudio.Models.Object3D.RotateMethod Rotate;
|
||||
|
||||
private global::PckStudio.Models.Object3D.UpdateRotationMethod UpdateRotation;
|
||||
private Action OnUpdateRotation;
|
||||
|
||||
private delegate void RotateMethod(float deltaX, float deltaY);
|
||||
|
||||
private delegate void UpdateRotationMethod();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,25 +3,25 @@ using System.Collections.Generic;
|
||||
|
||||
namespace PckStudio.Models
|
||||
{
|
||||
public class Object3DGroup : global::PckStudio.Models.Object3D
|
||||
public class Object3DGroup : Object3D
|
||||
{
|
||||
internal override global::PckStudio.Models.MinecraftModelView Viewport
|
||||
internal override MinecraftModelView Viewport
|
||||
{
|
||||
set
|
||||
{
|
||||
base.Viewport = value;
|
||||
foreach (global::PckStudio.Models.Object3D object3D in this.object3DList)
|
||||
foreach (Object3D object3D in object3DList)
|
||||
{
|
||||
object3D.Viewport = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override global::System.Drawing.Image Image
|
||||
public override System.Drawing.Image Image
|
||||
{
|
||||
set
|
||||
{
|
||||
foreach (global::PckStudio.Models.Object3D object3D in this.object3DList)
|
||||
foreach (Object3D object3D in object3DList)
|
||||
{
|
||||
object3D.Image = value;
|
||||
}
|
||||
@@ -30,17 +30,17 @@ namespace PckStudio.Models
|
||||
|
||||
internal override void Update()
|
||||
{
|
||||
global::PckStudio.Models.Matrix3D globalTransformation = this.globalTransformation * this.localTransformation;
|
||||
for (int i = 0; i < this.object3DList.Count; i++)
|
||||
Matrix3D globalTransformation = this.globalTransformation * localTransformation;
|
||||
for (int i = 0; i < object3DList.Count; i++)
|
||||
{
|
||||
this.object3DList[i].GlobalTransformation = globalTransformation;
|
||||
object3DList[i].GlobalTransformation = globalTransformation;
|
||||
}
|
||||
}
|
||||
|
||||
public override float HitTest(global::System.Drawing.PointF location)
|
||||
public override float HitTest(System.Drawing.PointF location)
|
||||
{
|
||||
float num = -1000f;
|
||||
foreach (global::PckStudio.Models.Object3D object3D in this.object3DList)
|
||||
foreach (Object3D object3D in object3DList)
|
||||
{
|
||||
float num2 = object3D.HitTest(location);
|
||||
if (num2 > num)
|
||||
@@ -51,19 +51,15 @@ namespace PckStudio.Models
|
||||
return num;
|
||||
}
|
||||
|
||||
public void Add(global::PckStudio.Models.Object3D object3D)
|
||||
public void Add(Object3D object3D)
|
||||
{
|
||||
if (object3D == this)
|
||||
{
|
||||
throw new global::System.ArgumentException("Cannot add Object3D into itself.");
|
||||
throw new ArgumentException("Cannot add Object3D into itself.");
|
||||
}
|
||||
this.object3DList.Add(object3D);
|
||||
object3DList.Add(object3D);
|
||||
}
|
||||
|
||||
public Object3DGroup()
|
||||
{
|
||||
}
|
||||
|
||||
private global::System.Collections.Generic.List<global::PckStudio.Models.Object3D> object3DList = new global::System.Collections.Generic.List<global::PckStudio.Models.Object3D>();
|
||||
private List<Object3D> object3DList = new List<Object3D>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,59 +4,28 @@ namespace PckStudio.Models
|
||||
{
|
||||
public struct Point3D
|
||||
{
|
||||
public Point3D(float x, float y, float z)
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
|
||||
public Point3D(float x, float y, float z)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
this.Z = z;
|
||||
(X, Y, Z) = (x, y, z);
|
||||
}
|
||||
|
||||
public static global::PckStudio.Models.Point3D Zero
|
||||
public static Point3D Zero => default(Point3D);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
get
|
||||
{
|
||||
return default(global::PckStudio.Models.Point3D);
|
||||
}
|
||||
return string.Format("({0};{1};{2})", X, Y, Z);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Concat(new object[]
|
||||
{
|
||||
"(",
|
||||
this.X,
|
||||
";",
|
||||
this.Y,
|
||||
";",
|
||||
this.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 global::PckStudio.Models.Point3D operator +(global::PckStudio.Models.Point3D a, global::PckStudio.Models.Point3D b)
|
||||
{
|
||||
return new global::PckStudio.Models.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 global::PckStudio.Models.Point3D operator -(global::PckStudio.Models.Point3D a, global::PckStudio.Models.Point3D b)
|
||||
{
|
||||
return new global::PckStudio.Models.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 global::PckStudio.Models.Point3D operator *(global::PckStudio.Models.Point3D p, float s)
|
||||
{
|
||||
return new global::PckStudio.Models.Point3D(p.X * s, p.Y * s, p.Z * s);
|
||||
}
|
||||
|
||||
public static global::PckStudio.Models.Point3D operator /(global::PckStudio.Models.Point3D p, float s)
|
||||
{
|
||||
return new global::PckStudio.Models.Point3D(p.X / s, p.Y / s, p.Z / s);
|
||||
}
|
||||
|
||||
public float X;
|
||||
|
||||
public float Y;
|
||||
|
||||
public float Z;
|
||||
public static Point3D operator /(Point3D p, float s) => new Point3D(p.X / s, p.Y / s, p.Z / s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,46 +4,46 @@ namespace PckStudio.Models
|
||||
{
|
||||
internal struct Texel
|
||||
{
|
||||
internal Texel(global::PckStudio.Models.TexturePlane texturePlane, int x, int y, global::System.Drawing.Color color)
|
||||
internal Texel(TexturePlane texturePlane, int x, int y, System.Drawing.Color color)
|
||||
{
|
||||
this.TexturePlane = texturePlane;
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
TexturePlane = texturePlane;
|
||||
X = x;
|
||||
Y = y;
|
||||
this.color = color;
|
||||
this.brush = new global::System.Drawing.SolidBrush(color);
|
||||
this.pen = new global::System.Drawing.Pen(global::System.Drawing.Color.White, 0.01f);
|
||||
brush = new System.Drawing.SolidBrush(color);
|
||||
pen = new System.Drawing.Pen(System.Drawing.Color.White, 0.01f);
|
||||
}
|
||||
|
||||
internal double Z
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.TexturePlane.ZOrder[this.X + 1, this.Y + 1];
|
||||
return TexturePlane.ZOrder[X + 1, Y + 1];
|
||||
}
|
||||
}
|
||||
|
||||
internal void Draw(global::System.Drawing.Graphics g)
|
||||
internal void Draw(System.Drawing.Graphics g)
|
||||
{
|
||||
global::System.Drawing.PointF[] points = new global::System.Drawing.PointF[]
|
||||
System.Drawing.PointF[] points = new System.Drawing.PointF[]
|
||||
{
|
||||
this.TexturePlane.Points[this.X, this.Y],
|
||||
this.TexturePlane.Points[this.X + 1, this.Y],
|
||||
this.TexturePlane.Points[this.X + 1, this.Y + 1],
|
||||
this.TexturePlane.Points[this.X, this.Y + 1]
|
||||
TexturePlane.Points[X, Y],
|
||||
TexturePlane.Points[X + 1, Y],
|
||||
TexturePlane.Points[X + 1, Y + 1],
|
||||
TexturePlane.Points[X, Y + 1]
|
||||
};
|
||||
g.FillPolygon(this.brush, points);
|
||||
g.FillPolygon(brush, points);
|
||||
}
|
||||
|
||||
internal global::PckStudio.Models.TexturePlane TexturePlane;
|
||||
internal TexturePlane TexturePlane;
|
||||
|
||||
internal int X;
|
||||
|
||||
internal int Y;
|
||||
|
||||
private global::System.Drawing.Color color;
|
||||
private System.Drawing.Color color;
|
||||
|
||||
private global::System.Drawing.Brush brush;
|
||||
private System.Drawing.Brush brush;
|
||||
|
||||
private global::System.Drawing.Pen pen;
|
||||
private System.Drawing.Pen pen;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ using System.Collections.Generic;
|
||||
|
||||
namespace PckStudio.Models
|
||||
{
|
||||
internal class TexelComparer : global::System.Collections.Generic.IComparer<global::PckStudio.Models.Texel>
|
||||
internal class TexelComparer : IComparer<Texel>
|
||||
{
|
||||
public int Compare(global::PckStudio.Models.Texel x, global::PckStudio.Models.Texel y)
|
||||
public int Compare(Texel x, Texel y)
|
||||
{
|
||||
return -x.Z.CompareTo(y.Z);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ namespace PckStudio.Models
|
||||
{
|
||||
public class TexturePlane : Object3D
|
||||
{
|
||||
public override System.Drawing.Image Image
|
||||
public override Image Image
|
||||
{
|
||||
set
|
||||
{
|
||||
this.Bitmap = (System.Drawing.Bitmap)value;
|
||||
Bitmap = (Bitmap)value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,31 +21,31 @@ namespace PckStudio.Models
|
||||
set
|
||||
{
|
||||
base.Viewport = value;
|
||||
if (this.bitmap != null && value != null)
|
||||
if (bitmap != null && value != null)
|
||||
{
|
||||
this.UpdateBitmap();
|
||||
UpdateBitmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Update()
|
||||
{
|
||||
if (this.Points == null || this.viewport == null)
|
||||
if (Points == null || viewport == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Matrix3D m = this.globalTransformation * this.localTransformation * this.originTranslation;
|
||||
for (int i = 0; i <= this.width; i++)
|
||||
Matrix3D m = globalTransformation * localTransformation * originTranslation;
|
||||
for (int i = 0; i <= width; i++)
|
||||
{
|
||||
for (int j = 0; j <= this.height; j++)
|
||||
for (int j = 0; j <= height; j++)
|
||||
{
|
||||
Point3D point3D = m * new Point3D((float)i, (float)j, 0f);
|
||||
this.Points[i, j] = this.viewport.Point3DTo2D(point3D);
|
||||
double num = (double)this.viewport.GetZOrder(point3D);
|
||||
this.ZOrder[i, j] += num;
|
||||
this.ZOrder[i + 1, j] += num;
|
||||
this.ZOrder[i, j + 1] += num;
|
||||
this.ZOrder[i + 1, j + 1] = num;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,108 +54,108 @@ namespace PckStudio.Models
|
||||
{
|
||||
set
|
||||
{
|
||||
if (this.viewport == null)
|
||||
if (viewport == null)
|
||||
{
|
||||
this.bitmap = value;
|
||||
bitmap = value;
|
||||
return;
|
||||
}
|
||||
this.texelList.Clear();
|
||||
if (this.bitmap != null)
|
||||
texelList.Clear();
|
||||
if (bitmap != null)
|
||||
{
|
||||
this.viewport.RemoveTexelsOf(this);
|
||||
this.Points = null;
|
||||
viewport.RemoveTexelsOf(this);
|
||||
Points = null;
|
||||
}
|
||||
this.bitmap = value;
|
||||
if (this.bitmap != null)
|
||||
bitmap = value;
|
||||
if (bitmap != null)
|
||||
{
|
||||
this.UpdateBitmap();
|
||||
this.Update();
|
||||
UpdateBitmap();
|
||||
Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateBitmap()
|
||||
{
|
||||
this.width = this.bitmap.Width;
|
||||
this.height = this.bitmap.Height;
|
||||
this.visibility = new bool[this.width, this.height];
|
||||
for (int i = 0; i < this.width; i++)
|
||||
width = bitmap.Width;
|
||||
height = bitmap.Height;
|
||||
visibility = new bool[width, height];
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < this.height; j++)
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
System.Drawing.Color pixel = this.bitmap.GetPixel(i, j);
|
||||
int num = this.flipHorizontally ? (this.width - i - 1) : i;
|
||||
int num2 = this.flipVertically ? j : (this.height - j - 1);
|
||||
Color pixel = bitmap.GetPixel(i, j);
|
||||
int num = flipHorizontally ? (width - i - 1) : i;
|
||||
int num2 = flipVertically ? j : (height - j - 1);
|
||||
if (pixel.A == 0)
|
||||
{
|
||||
this.visibility[num, num2] = false;
|
||||
visibility[num, num2] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.visibility[num, num2] = true;
|
||||
visibility[num, num2] = true;
|
||||
Texel texel = new Texel(this, num, num2, pixel);
|
||||
this.viewport.AddTexel(texel);
|
||||
this.texelList.Add(texel);
|
||||
viewport.AddTexel(texel);
|
||||
texelList.Add(texel);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.Points = new System.Drawing.PointF[this.width + 1, this.height + 1];
|
||||
this.ZOrder = new double[this.width + 2, this.height + 2];
|
||||
Points = new PointF[width + 1, height + 1];
|
||||
ZOrder = new double[width + 2, height + 2];
|
||||
}
|
||||
|
||||
public TexturePlane(System.Drawing.Image bitmap, System.Drawing.Rectangle srcRect, Point3D origin, Point3D normal, Effects effects)
|
||||
public TexturePlane(Image bitmap, Rectangle srcRect, Point3D origin, Point3D normal, Effects effects)
|
||||
{
|
||||
base.Origin = origin;
|
||||
Origin = origin;
|
||||
this.normal = normal;
|
||||
if (bitmap == null)
|
||||
{
|
||||
this.Bitmap = null;
|
||||
Bitmap = null;
|
||||
return;
|
||||
}
|
||||
System.Drawing.Bitmap bitmap2 = new System.Drawing.Bitmap(srcRect.Width, srcRect.Height);
|
||||
using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap2))
|
||||
Bitmap bitmap2 = new Bitmap(srcRect.Width, srcRect.Height);
|
||||
using (Graphics graphics = Graphics.FromImage(bitmap2))
|
||||
{
|
||||
graphics.DrawImage(bitmap, new System.Drawing.Rectangle(0, 0, bitmap2.Width, bitmap2.Height), srcRect, System.Drawing.GraphicsUnit.Pixel);
|
||||
graphics.DrawImage(bitmap, new Rectangle(0, 0, bitmap2.Width, bitmap2.Height), srcRect, GraphicsUnit.Pixel);
|
||||
}
|
||||
this.flipHorizontally = ((byte)(effects & Effects.FlipHorizontally) == 1);
|
||||
this.flipVertically = ((byte)(effects & Effects.FlipVertically) == 2);
|
||||
this.Bitmap = bitmap2;
|
||||
flipHorizontally = (byte)(effects & Effects.FlipHorizontally) == 1;
|
||||
flipVertically = (byte)(effects & Effects.FlipVertically) == 2;
|
||||
Bitmap = bitmap2;
|
||||
}
|
||||
|
||||
public override float HitTest(System.Drawing.PointF location)
|
||||
public override float HitTest(PointF location)
|
||||
{
|
||||
if (this.Points == null)
|
||||
if (Points == null)
|
||||
{
|
||||
return -1000f;
|
||||
}
|
||||
System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
|
||||
graphicsPath.AddPolygon(new System.Drawing.PointF[]
|
||||
GraphicsPath graphicsPath = new GraphicsPath();
|
||||
graphicsPath.AddPolygon(new PointF[]
|
||||
{
|
||||
this.Points[0, 0],
|
||||
this.Points[this.Points.GetLength(0) - 1, 0],
|
||||
this.Points[this.Points.GetLength(0) - 1, this.Points.GetLength(1) - 1],
|
||||
this.Points[0, this.Points.GetLength(1) - 1]
|
||||
Points[0, 0],
|
||||
Points[Points.GetLength(0) - 1, 0],
|
||||
Points[Points.GetLength(0) - 1, Points.GetLength(1) - 1],
|
||||
Points[0, Points.GetLength(1) - 1]
|
||||
});
|
||||
System.Drawing.Region region = new System.Drawing.Region(graphicsPath);
|
||||
Region region = new Region(graphicsPath);
|
||||
if (region.IsVisible(location))
|
||||
{
|
||||
for (int i = 0; i < this.Points.GetLength(0) - 1; i++)
|
||||
for (int i = 0; i < Points.GetLength(0) - 1; i++)
|
||||
{
|
||||
for (int j = 0; j < this.Points.GetLength(1) - 1; j++)
|
||||
for (int j = 0; j < Points.GetLength(1) - 1; j++)
|
||||
{
|
||||
if (this.visibility[i, j])
|
||||
if (visibility[i, j])
|
||||
{
|
||||
graphicsPath.Reset();
|
||||
graphicsPath.AddPolygon(new System.Drawing.PointF[]
|
||||
graphicsPath.AddPolygon(new PointF[]
|
||||
{
|
||||
this.Points[i, j],
|
||||
this.Points[i + 1, j],
|
||||
this.Points[i + 1, j + 1],
|
||||
this.Points[i, j + 1]
|
||||
Points[i, j],
|
||||
Points[i + 1, j],
|
||||
Points[i + 1, j + 1],
|
||||
Points[i, j + 1]
|
||||
});
|
||||
if (graphicsPath.IsVisible(location))
|
||||
{
|
||||
return (this.globalTransformation * this.localTransformation * this.originTranslation * new Point3D((float)i, (float)j, 0f)).Z;
|
||||
return (globalTransformation * localTransformation * originTranslation * new Point3D(i, j, 0f)).Z;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,9 +164,9 @@ namespace PckStudio.Models
|
||||
return -1000f;
|
||||
}
|
||||
|
||||
private System.Collections.Generic.List<Texel> texelList = new System.Collections.Generic.List<Texel>();
|
||||
private List<Texel> texelList = new List<Texel>();
|
||||
|
||||
internal System.Drawing.PointF[,] Points;
|
||||
internal PointF[,] Points;
|
||||
|
||||
internal double[,] ZOrder;
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace PckStudio.Models
|
||||
|
||||
private bool[,] visibility;
|
||||
|
||||
private System.Drawing.Bitmap bitmap;
|
||||
private Bitmap bitmap;
|
||||
|
||||
private bool flipHorizontally;
|
||||
|
||||
|
||||
@@ -30,37 +30,36 @@ namespace PckStudio.Forms
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.minecraftModelView1 = new PckStudio.Models.MinecraftModelView(this.components);
|
||||
this.ModelView = new PckStudio.Models.MinecraftModelView(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// minecraftModelView1
|
||||
// ModelView
|
||||
//
|
||||
this.minecraftModelView1.BackColor = System.Drawing.Color.DarkGray;
|
||||
this.minecraftModelView1.BackGradientColor1 = System.Drawing.SystemColors.ActiveCaptionText;
|
||||
this.minecraftModelView1.BackGradientColor2 = System.Drawing.SystemColors.ActiveCaptionText;
|
||||
this.minecraftModelView1.BackgroundType = PckStudio.Models.BackgroundTypes.Color;
|
||||
this.minecraftModelView1.DegreesX = 0;
|
||||
this.minecraftModelView1.DegreesY = 0;
|
||||
this.minecraftModelView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.minecraftModelView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.minecraftModelView1.ForeColor = System.Drawing.Color.Black;
|
||||
this.minecraftModelView1.FOV = 70;
|
||||
this.minecraftModelView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.minecraftModelView1.Name = "minecraftModelView1";
|
||||
this.minecraftModelView1.Projection = PckStudio.Models.ProjectionTypes.Perspective;
|
||||
this.minecraftModelView1.ShowUsername = false;
|
||||
this.minecraftModelView1.Size = new System.Drawing.Size(418, 568);
|
||||
this.minecraftModelView1.TabIndex = 1;
|
||||
this.minecraftModelView1.Text = "minecraftModelView1";
|
||||
this.minecraftModelView1.Username = "";
|
||||
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";
|
||||
//
|
||||
// SkinPreview
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(418, 568);
|
||||
this.Controls.Add(this.minecraftModelView1);
|
||||
this.Controls.Add(this.ModelView);
|
||||
this.Name = "SkinPreview";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "SkinPreview";
|
||||
this.Load += new System.EventHandler(this.SkinPreview_Load);
|
||||
this.ResumeLayout(false);
|
||||
@@ -69,6 +68,6 @@ namespace PckStudio.Forms
|
||||
|
||||
#endregion
|
||||
|
||||
private PckStudio.Models.MinecraftModelView minecraftModelView1;
|
||||
private PckStudio.Models.MinecraftModelView ModelView;
|
||||
}
|
||||
}
|
||||
@@ -14,75 +14,20 @@ namespace PckStudio.Forms
|
||||
public partial class SkinPreview : Form
|
||||
{
|
||||
Image Texture;
|
||||
public SkinPreview(Image img)
|
||||
ModelBase Model;
|
||||
|
||||
public SkinPreview(Image img, ModelBase model = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
Texture = img;
|
||||
}
|
||||
private void SkinPreview_Load(object sender, EventArgs e)
|
||||
{
|
||||
RenderModl(Texture);
|
||||
Model = model ?? new Steve64x32Model(Texture);
|
||||
}
|
||||
|
||||
|
||||
public void RenderModl(Image Source)
|
||||
private void SkinPreview_Load(object sender, EventArgs e) => RenderModel(Texture);
|
||||
|
||||
public void RenderModel(Image source)
|
||||
{
|
||||
|
||||
//RenderBox
|
||||
Image source = Source;
|
||||
Object3D object3D = new Box(source, new System.Drawing.Rectangle(8, 0, 0x10, 8), new System.Drawing.Rectangle(0, 8, 0x20, 8), new Point3D(0f, 0f, 0f), Effects.None);
|
||||
Object3D object3D2 = new Box(source, new System.Drawing.Rectangle(0x28, 0, 0x10, 8), new System.Drawing.Rectangle(0x20, 8, 0x20, 8), new Point3D(0f, 0f, 0f), Effects.None);
|
||||
Object3D object3D3 = new Box(source, new System.Drawing.Rectangle(0x2C, 0x10, 8, 4), new System.Drawing.Rectangle(0x28, 0x14, 0x20, 0xC), new Point3D(0f, 4f, 0f), Effects.FlipHorizontally);
|
||||
Object3D object3D4 = new Box(source, new System.Drawing.Rectangle(0x2C, 0x10, 8, 4), new System.Drawing.Rectangle(0x28, 0x14, 0x20, 0xC), new Point3D(0f, 4f, 0f), Effects.None);
|
||||
Object3D object3D5 = new Box(source, new System.Drawing.Rectangle(4, 0x10, 8, 4), new System.Drawing.Rectangle(0, 0x14, 0x10, 0xC), new Point3D(0f, 6f, 0f), Effects.FlipHorizontally);
|
||||
Object3D object3D6 = new Box(source, new System.Drawing.Rectangle(4, 0x10, 8, 4), new System.Drawing.Rectangle(0, 0x14, 0x10, 0xC), new Point3D(0f, 6f, 0f), Effects.None);
|
||||
Object3D object3D7 = new Box(source, new System.Drawing.Rectangle(0x14, 0x10, 0x10, 4), new System.Drawing.Rectangle(0x10, 0x14, 0x18, 0xC), new Point3D(0f, 0f, 0f), Effects.None);
|
||||
Object3DGroup object3DGroup = new Object3DGroup();
|
||||
|
||||
|
||||
//RenderGroup
|
||||
object3D2.Scale = 1.16f;
|
||||
object3DGroup.RotationOrder = RotationOrders.XY;
|
||||
object3DGroup.MinDegrees1 = -80f;
|
||||
object3DGroup.MaxDegrees1 = 80f;
|
||||
object3DGroup.MinDegrees2 = -57f;
|
||||
object3DGroup.MaxDegrees2 = 57f;
|
||||
object3DGroup.Add(object3D);
|
||||
object3DGroup.Add(object3D2);
|
||||
object3DGroup.Position = new Point3D(0f, 8f, 0f);
|
||||
object3DGroup.Origin = new Point3D(0f, -4f, 0f);
|
||||
object3DGroup.RotationOrder = RotationOrders.XY;
|
||||
object3D7.Position = new Point3D(0f, 2f, 0f);
|
||||
object3D3.Position = new Point3D(6f, 6f, 0f);
|
||||
object3D3.RotationOrder = RotationOrders.ZX;
|
||||
object3D3.MinDegrees1 = 0f;
|
||||
object3D3.MaxDegrees1 = 160f;
|
||||
object3D3.MinDegrees2 = -170f;
|
||||
object3D3.MaxDegrees2 = 60f;
|
||||
object3D4.Position = new Point3D(-6f, 6f, 0f);
|
||||
object3D4.RotationOrder = RotationOrders.ZX;
|
||||
object3D4.MinDegrees1 = -160f;
|
||||
object3D4.MaxDegrees1 = 0f;
|
||||
object3D4.MinDegrees2 = -170f;
|
||||
object3D4.MaxDegrees2 = 60f;
|
||||
object3D5.Position = new Point3D(2f, -4f, 0f);
|
||||
object3D5.RotationOrder = RotationOrders.ZX;
|
||||
object3D5.MinDegrees1 = 0f;
|
||||
object3D5.MaxDegrees1 = 70f;
|
||||
object3D5.MinDegrees2 = -110f;
|
||||
object3D5.MaxDegrees2 = 60f;
|
||||
object3D6.Position = new Point3D(-2f, -4f, 0f);
|
||||
object3D6.RotationOrder = RotationOrders.ZX;
|
||||
object3D6.MinDegrees1 = -70f;
|
||||
object3D6.MaxDegrees1 = 0f;
|
||||
object3D6.MinDegrees2 = -110f;
|
||||
object3D6.MaxDegrees2 = 60f;
|
||||
minecraftModelView1.AddDynamic(object3DGroup);
|
||||
minecraftModelView1.AddStatic(object3D7);
|
||||
minecraftModelView1.AddDynamic(object3D4);
|
||||
minecraftModelView1.AddDynamic(object3D3);
|
||||
minecraftModelView1.AddDynamic(object3D6);
|
||||
minecraftModelView1.AddDynamic(object3D5);
|
||||
Model.AddToModelView(ModelView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
<Compile Include="Classes\IO\PCK\PCKFileWriter.cs" />
|
||||
<Compile Include="Classes\IO\StreamDataReader.cs" />
|
||||
<Compile Include="Classes\IO\StreamDataWriter.cs" />
|
||||
<Compile Include="Classes\Models\DefaultModels\CharacterModel.cs" />
|
||||
<Compile Include="Classes\Models\DefaultModels\Steve64x32Model.cs" />
|
||||
<Compile Include="Classes\Models\DefaultModels\ModelBase.cs" />
|
||||
<Compile Include="Classes\Models\DefaultModels\Texture.cs" />
|
||||
<Compile Include="Classes\Models\DefaultModels\TextureSelector.cs">
|
||||
|
||||
Reference in New Issue
Block a user