diff --git a/ClassicalSharp.csproj b/ClassicalSharp.csproj
index d907eef38..b96f2fcbf 100644
--- a/ClassicalSharp.csproj
+++ b/ClassicalSharp.csproj
@@ -122,6 +122,7 @@
+
diff --git a/Model/ChickenModel.cs b/Model/ChickenModel.cs
index 5ad584b59..d1b6a110c 100644
--- a/Model/ChickenModel.cs
+++ b/Model/ChickenModel.cs
@@ -16,8 +16,10 @@ namespace ClassicalSharp.Model {
Set.Head2 = MakeHead2(); // TODO: Find a more appropriate name.
Set.Head3 = MakeHead3();
Set.Torso = MakeTorso();
- Set.LeftLegFront = MakeLeg( -0.1875f, 0f, -0.125f, -0.0625f );
- Set.RightLegFront = MakeLeg( 0f, 0.1875f, 0.0625f, 0.125f );
+ Set.LeftLeg = MakeLeg( -0.1875f, 0f, -0.125f, -0.0625f );
+ Set.RightLeg = MakeLeg( 0f, 0.1875f, 0.0625f, 0.125f );
+ Set.LeftWing = MakeWing( -0.25f, -0.1875f );
+ Set.RightWing = MakeWing( 0.1875f, 0.25f );
vertices = null;
DefaultSkinTextureId = graphics.LoadTexture( "chicken.png" );
@@ -36,24 +38,11 @@ namespace ClassicalSharp.Model {
}
ModelPart MakeTorso() {
- index = 0;
- const float x1 = -0.1875f, x2 = 0.1875f, y1 = 0.3125f, y2 = 0.6875f, z1 = -0.25f, z2 = 0.25f;
-
- YPlane( 18, 15, 6, 8, x1, x2, z1, z2, y2, false ); // top
- YPlane( 6, 15, 6, 8, x2, x1, z1, z2, y1, false ); // bottom
- ZPlane( 6, 9, 6, 6, x2, x1, y1, y2, z1, false ); // front
- ZPlane( 12, 9, 6, 6, x2, x1, y2, y1, z2, false ); // back
- XPlane( 12, 15, 6, 8, y1, y2, z2, z1, x1, false ); // left
- XPlane( 0, 15, 6, 8, y2, y1, z2, z1, x2, false ); // right
- // rotate left and right 90 degrees
- for( int i = index - 12; i < index; i++ ) {
- VertexPos3fTex2fCol4b vertex = vertices[i];
- float z = vertex.Z;
- vertex.Z = vertex.Y;
- vertex.Y = z;
- vertices[i] = vertex;
- }
- return new ModelPart( vertices, 6 * 6, graphics );
+ return MakeRotatedPart( 0, 9, 6, 8, 6, 6, 6, 8, -0.1875f, 0.1875f, 0.3125f, 0.6875f, -0.25f, 0.25f, false );
+ }
+
+ ModelPart MakeWing( float x1, float x2 ) {
+ return MakePart( 24, 13, 6, 4, 1, 6, 1, 4, x1, x2, 0.4375f, 0.6875f, -0.1875f, 0.1875f, false );
}
ModelPart MakeLeg( float x1, float x2, float legX1, float legX2 ) {
@@ -78,8 +67,10 @@ namespace ClassicalSharp.Model {
DrawRotateX( 0, 0.5625f, -0.1875f, -pitch, Set.Head2 );
DrawRotateX( 0, 0.5625f, -0.1875f, -pitch, Set.Head3 );
Set.Torso.Render();
- DrawRotateX( 0, 0.3125f, 0.0625f, leftLegXRot, Set.LeftLegFront );
- DrawRotateX( 0, 0.3125f, 0.0625f, rightLegXRot, Set.RightLegFront );
+ DrawRotateX( 0, 0.3125f, 0.0625f, leftLegXRot, Set.LeftLeg );
+ DrawRotateX( 0, 0.3125f, 0.0625f, rightLegXRot, Set.RightLeg );
+ DrawRotateZ( -0.1875f, 0.6875f, 0, -Math.Abs( leftArmXRot ), Set.LeftWing );
+ DrawRotateZ( 0.1875f, 0.6875f, 0, Math.Abs( rightArmXRot ), Set.RightWing );
}
public override void Dispose() {
@@ -89,15 +80,17 @@ namespace ClassicalSharp.Model {
class ModelSet {
- public ModelPart Head, Head2, Head3, Torso, LeftLegFront, RightLegFront;
+ public ModelPart Head, Head2, Head3, Torso, LeftLeg, RightLeg, LeftWing, RightWing;
public void Dispose() {
- RightLegFront.Dispose();
- LeftLegFront.Dispose();
+ RightLeg.Dispose();
+ LeftLeg.Dispose();
Torso.Dispose();
Head.Dispose();
Head2.Dispose();
Head3.Dispose();
+ LeftWing.Dispose();
+ RightWing.Dispose();
}
}
}
diff --git a/Model/IModel.cs b/Model/IModel.cs
index 906a2ff3d..f98ceabf2 100644
--- a/Model/IModel.cs
+++ b/Model/IModel.cs
@@ -57,8 +57,28 @@ namespace ClassicalSharp.Model {
YPlane( x + sidesW + bodyW, y, endsW, endsH, x2, x1, z1, z2, y1, _64x64 ); // bottom
ZPlane( x + sidesW, y + endsH, bodyW, bodyH, x2, x1, y1, y2, z1, _64x64 ); // front
ZPlane( x + sidesW + bodyW + sidesW, y + endsH, bodyW, bodyH, x1, x2, y1, y2, z2, _64x64 ); // back
- XPlane( x + sidesW + bodyW, y + endsH, sidesW, sidesH, z1, z2, y1, y2, x1, _64x64 ); // left
- XPlane( x, y + endsH, sidesW, sidesH, z2, z1, y1, y2, x2, _64x64 ); // right
+ XPlane( x, y + endsH, sidesW, sidesH, z2, z1, y1, y2, x2, _64x64 ); // left
+ XPlane( x + sidesW + bodyW, y + endsH, sidesW, sidesH, z1, z2, y1, y2, x1, _64x64 ); // right
+ return new ModelPart( vertices, 6 * 6, graphics );
+ }
+
+ protected ModelPart MakeRotatedPart( int x, int y, int sidesW, int sidesH, int endsW, int endsH, int bodyW, int bodyH,
+ float x1, float x2, float y1, float y2, float z1, float z2, bool _64x64 ) {
+ index = 0;
+ YPlane( x + sidesW + bodyW + sidesW, y + endsH, bodyW, bodyH, x1, x2, z1, z2, y2, _64x64 ); // top
+ YPlane( x + sidesW, y + endsH, bodyW, bodyH, x2, x1, z1, z2, y1, _64x64 ); // bottom
+ ZPlane( x + sidesW, y, endsW, endsH, x2, x1, y1, y2, z1, _64x64 ); // front
+ ZPlane( x + sidesW + bodyW, y, endsW, endsH, x2, x1, y2, y1, z2, _64x64 ); // back
+ XPlane( x, y + endsH, sidesW, sidesH, y2, y1, z2, z1, x2, _64x64 ); // left
+ XPlane( x + sidesW + bodyW, y + endsH, sidesW, sidesH, y1, y2, z2, z1, x1, _64x64 ); // right
+ // rotate left and right 90 degrees
+ for( int i = index - 12; i < index; i++ ) {
+ VertexPos3fTex2fCol4b vertex = vertices[i];
+ float z = vertex.Z;
+ vertex.Z = vertex.Y;
+ vertex.Y = z;
+ vertices[i] = vertex;
+ }
return new ModelPart( vertices, 6 * 6, graphics );
}
@@ -111,6 +131,15 @@ namespace ClassicalSharp.Model {
graphics.PopMatrix();
}
+ protected void DrawRotateZ( float x, float y, float z, float angleX, ModelPart part ) {
+ graphics.PushMatrix();
+ graphics.Translate( x, y, z );
+ graphics.RotateZ( angleX ); // z is ignored anyways.. probably should remove it from arguments.
+ graphics.Translate( -x, -y, -z );
+ part.Render();
+ graphics.PopMatrix();
+ }
+
protected void DrawRotateXZ( float x, float y, float z, float angleX, float angleZ, ModelPart part ) {
graphics.PushMatrix();
graphics.Translate( x, y, z );
diff --git a/Model/ModelCache.cs b/Model/ModelCache.cs
index 71d71f3a8..cdd52d276 100644
--- a/Model/ModelCache.cs
+++ b/Model/ModelCache.cs
@@ -43,7 +43,9 @@ namespace ClassicalSharp.Model {
return new PigModel( window );
} else if( modelName == "skeleton" ) {
return new SkeletonModel( window );
- } else if( modelName == "zombie" ) {
+ } else if( modelName == "spider" ) {
+ return new SpiderModel( window );
+ }else if( modelName == "zombie" ) {
return new ZombieModel( window );
}
return null;
diff --git a/Model/PigModel.cs b/Model/PigModel.cs
index de8908141..b92a8012c 100644
--- a/Model/PigModel.cs
+++ b/Model/PigModel.cs
@@ -28,25 +28,7 @@ namespace ClassicalSharp.Model {
}
ModelPart MakeTorso() {
- //return MakePart( 28, 8, 8, 16, 10, 4, 8, 16, -0.3125f, 0.3125f, 0.375f, 0.875f, -0.5f, 0.5f, false );
- index = 0;
- const float x1 = -0.3125f, x2 = 0.3125f, y1 = 0.375f, y2 = 0.875f, z1 = -0.5f, z2 = 0.5f;
-
- YPlane( 54, 16, 10, 16, x1, x2, z1, z2, y2, false ); // top
- YPlane( 36, 16, 10, 16, x2, x1, z1, z2, y1, false ); // bottom
- ZPlane( 36, 8, 10, 8, x2, x1, y1, y2, z1, false ); // front
- ZPlane( 46, 8, 10, 8, x2, x1, y2, y1, z2, false ); // back
- XPlane( 46, 16, 8, 16, y1, y2, z2, z1, x1, false ); // left
- XPlane( 28, 16, 8, 16, y2, y1, z2, z1, x2, false ); // right
- // rotate left and right 90 degrees
- for( int i = index - 12; i < index; i++ ) {
- VertexPos3fTex2fCol4b vertex = vertices[i];
- float z = vertex.Z;
- vertex.Z = vertex.Y;
- vertex.Y = z;
- vertices[i] = vertex;
- }
- return new ModelPart( vertices, 6 * 6, graphics );
+ return MakeRotatedPart( 28, 8, 8, 16, 10, 8, 10, 16, -0.3125f, 0.3125f, 0.375f, 0.875f, -0.5f, 0.5f, false );
}
ModelPart MakeLeg( float x1, float x2, float z1, float z2 ) {
diff --git a/Model/SpiderModel.cs b/Model/SpiderModel.cs
new file mode 100644
index 000000000..2e5413819
--- /dev/null
+++ b/Model/SpiderModel.cs
@@ -0,0 +1,81 @@
+using OpenTK;
+using System;
+using System.Drawing;
+using ClassicalSharp.GraphicsAPI;
+using ClassicalSharp.Renderers;
+
+namespace ClassicalSharp.Model {
+
+ public class SpiderModel : IModel {
+
+ ModelSet Set;
+ public SpiderModel( Game window ) : base( window ) {
+ vertices = new VertexPos3fTex2fCol4b[6 * 6];
+ Set = new ModelSet();
+ Set.Head = MakeHead();
+ Set.Link = MakeLink();
+ Set.End = MakeEnd();
+ //Set.LeftLegFront = MakeLeg( -0.1875f, 0f, -0.125f, -0.0625f );
+ //Set.RightLegFront = MakeLeg( 0f, 0.1875f, 0.0625f, 0.125f );
+ vertices = null;
+
+ DefaultSkinTextureId = graphics.LoadTexture( "spider.png" );
+ }
+
+ ModelPart MakeHead() {
+ return MakePart( 32, 4, 8, 8, 8, 8, 8, 8, -0.25f, 0.25f, 0.25f, 0.75f, -0.6875f, -0.1875f, false );
+ }
+
+ ModelPart MakeLink() {
+ return MakePart( 0, 0, 6, 6, 6, 6, 6, 6, -0.1875f, 0.1875f, 0.3125f, 0.6875f, 0.1875f, -0.1875f, false );
+ }
+
+ ModelPart MakeEnd() {
+ index = 0;
+ const float x1 = -0.3125f, x2 = 0.3125f, y1 = 0.25f, y2 = 0.75f, z1 = 0.1875f, z2 = 0.9375f;
+
+ YPlane( 12, 12, 10, 12, x2, x1, z2, z1, y2, false ); // top
+ YPlane( 22, 12, 10, 12, x2, x1, z1, z2, y1, false ); // bottom
+ ZPlane( 12, 24, 10, 8, x2, x1, y1, y2, z1, false ); // front
+ ZPlane( 22, 24, 10, 8, x2, x1, y2, y1, z2, false ); // back
+ XPlane( 0, 24, 12, 8, z2, z1, y1, y2, x1, false ); // left
+ XPlane( 32, 24, 12, 8, z2, z1, y2, y1, x2, false ); // right
+ return new ModelPart( vertices, 6 * 6, graphics );
+ }
+
+ public override float NameYOffset {
+ get { return 1.0125f; }
+ }
+
+ protected override void DrawPlayerModel( Player player, PlayerRenderer renderer ) {
+ graphics.Texturing = true;
+ int texId = DefaultSkinTextureId;
+ graphics.Bind2DTexture( texId );
+ graphics.AlphaTest = true;
+
+ DrawRotateX( 0, 0.5625f, -0.1875f, -pitch, Set.Head );
+ Set.Link.Render();
+ Set.End.Render();
+ //DrawRotateX( 0, 0.3125f, 0.0625f, leftLegXRot, Set.LeftLegFront );
+ //DrawRotateX( 0, 0.3125f, 0.0625f, rightLegXRot, Set.RightLegFront );
+ }
+
+ public override void Dispose() {
+ Set.Dispose();
+ graphics.DeleteTexture( DefaultSkinTextureId );
+ }
+
+ class ModelSet {
+
+ public ModelPart Head, Link, End, LegLeft, LegRight;
+
+ public void Dispose() {
+ //RightLegFront.Dispose();
+ //LeftLegFront.Dispose();
+ End.Dispose();
+ Head.Dispose();
+ Link.Dispose();
+ }
+ }
+ }
+}
\ No newline at end of file