mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 09:06:55 -04:00
Started skeleton model, add wings to chicken model.
This commit is contained in:
parent
b147f5beec
commit
71e3ae89c9
@ -122,6 +122,7 @@
|
|||||||
<Compile Include="Model\PigModel.cs" />
|
<Compile Include="Model\PigModel.cs" />
|
||||||
<Compile Include="Model\PlayerModel.cs" />
|
<Compile Include="Model\PlayerModel.cs" />
|
||||||
<Compile Include="Model\SkeletonModel.cs" />
|
<Compile Include="Model\SkeletonModel.cs" />
|
||||||
|
<Compile Include="Model\SpiderModel.cs" />
|
||||||
<Compile Include="Model\ZombieModel.cs" />
|
<Compile Include="Model\ZombieModel.cs" />
|
||||||
<Compile Include="Network\Enums.cs" />
|
<Compile Include="Network\Enums.cs" />
|
||||||
<Compile Include="Network\FastNetReader.cs" />
|
<Compile Include="Network\FastNetReader.cs" />
|
||||||
|
@ -16,8 +16,10 @@ namespace ClassicalSharp.Model {
|
|||||||
Set.Head2 = MakeHead2(); // TODO: Find a more appropriate name.
|
Set.Head2 = MakeHead2(); // TODO: Find a more appropriate name.
|
||||||
Set.Head3 = MakeHead3();
|
Set.Head3 = MakeHead3();
|
||||||
Set.Torso = MakeTorso();
|
Set.Torso = MakeTorso();
|
||||||
Set.LeftLegFront = MakeLeg( -0.1875f, 0f, -0.125f, -0.0625f );
|
Set.LeftLeg = MakeLeg( -0.1875f, 0f, -0.125f, -0.0625f );
|
||||||
Set.RightLegFront = MakeLeg( 0f, 0.1875f, 0.0625f, 0.125f );
|
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;
|
vertices = null;
|
||||||
|
|
||||||
DefaultSkinTextureId = graphics.LoadTexture( "chicken.png" );
|
DefaultSkinTextureId = graphics.LoadTexture( "chicken.png" );
|
||||||
@ -36,24 +38,11 @@ namespace ClassicalSharp.Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ModelPart MakeTorso() {
|
ModelPart MakeTorso() {
|
||||||
index = 0;
|
return MakeRotatedPart( 0, 9, 6, 8, 6, 6, 6, 8, -0.1875f, 0.1875f, 0.3125f, 0.6875f, -0.25f, 0.25f, false );
|
||||||
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 );
|
|
||||||
|
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 ) {
|
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.Head2 );
|
||||||
DrawRotateX( 0, 0.5625f, -0.1875f, -pitch, Set.Head3 );
|
DrawRotateX( 0, 0.5625f, -0.1875f, -pitch, Set.Head3 );
|
||||||
Set.Torso.Render();
|
Set.Torso.Render();
|
||||||
DrawRotateX( 0, 0.3125f, 0.0625f, leftLegXRot, Set.LeftLegFront );
|
DrawRotateX( 0, 0.3125f, 0.0625f, leftLegXRot, Set.LeftLeg );
|
||||||
DrawRotateX( 0, 0.3125f, 0.0625f, rightLegXRot, Set.RightLegFront );
|
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() {
|
public override void Dispose() {
|
||||||
@ -89,15 +80,17 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
class ModelSet {
|
class ModelSet {
|
||||||
|
|
||||||
public ModelPart Head, Head2, Head3, Torso, LeftLegFront, RightLegFront;
|
public ModelPart Head, Head2, Head3, Torso, LeftLeg, RightLeg, LeftWing, RightWing;
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
RightLegFront.Dispose();
|
RightLeg.Dispose();
|
||||||
LeftLegFront.Dispose();
|
LeftLeg.Dispose();
|
||||||
Torso.Dispose();
|
Torso.Dispose();
|
||||||
Head.Dispose();
|
Head.Dispose();
|
||||||
Head2.Dispose();
|
Head2.Dispose();
|
||||||
Head3.Dispose();
|
Head3.Dispose();
|
||||||
|
LeftWing.Dispose();
|
||||||
|
RightWing.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,28 @@ namespace ClassicalSharp.Model {
|
|||||||
YPlane( x + sidesW + bodyW, y, endsW, endsH, x2, x1, z1, z2, y1, _64x64 ); // bottom
|
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, 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
|
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 ); // left
|
||||||
XPlane( x, y + endsH, sidesW, sidesH, z2, z1, y1, y2, x2, _64x64 ); // right
|
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 );
|
return new ModelPart( vertices, 6 * 6, graphics );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,6 +131,15 @@ namespace ClassicalSharp.Model {
|
|||||||
graphics.PopMatrix();
|
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 ) {
|
protected void DrawRotateXZ( float x, float y, float z, float angleX, float angleZ, ModelPart part ) {
|
||||||
graphics.PushMatrix();
|
graphics.PushMatrix();
|
||||||
graphics.Translate( x, y, z );
|
graphics.Translate( x, y, z );
|
||||||
|
@ -43,6 +43,8 @@ namespace ClassicalSharp.Model {
|
|||||||
return new PigModel( window );
|
return new PigModel( window );
|
||||||
} else if( modelName == "skeleton" ) {
|
} else if( modelName == "skeleton" ) {
|
||||||
return new SkeletonModel( window );
|
return new SkeletonModel( window );
|
||||||
|
} else if( modelName == "spider" ) {
|
||||||
|
return new SpiderModel( window );
|
||||||
}else if( modelName == "zombie" ) {
|
}else if( modelName == "zombie" ) {
|
||||||
return new ZombieModel( window );
|
return new ZombieModel( window );
|
||||||
}
|
}
|
||||||
|
@ -28,25 +28,7 @@ namespace ClassicalSharp.Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ModelPart MakeTorso() {
|
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 );
|
return MakeRotatedPart( 28, 8, 8, 16, 10, 8, 10, 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 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelPart MakeLeg( float x1, float x2, float z1, float z2 ) {
|
ModelPart MakeLeg( float x1, float x2, float z1, float z2 ) {
|
||||||
|
81
Model/SpiderModel.cs
Normal file
81
Model/SpiderModel.cs
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user