Drop non-player models.

This commit is contained in:
UnknownShadow200 2015-04-06 10:51:27 +10:00
parent de9dd69834
commit 0b0419c007
11 changed files with 2 additions and 851 deletions

View file

@ -116,18 +116,10 @@
<Compile Include="Map.cs" />
<Compile Include="MeshBuilders\ChunkMeshBuilder.cs" />
<Compile Include="MeshBuilders\ChunkMeshBuilderTex2Col4.cs" />
<Compile Include="Model\BlockModel.cs" />
<Compile Include="Model\ChickenModel.cs" />
<Compile Include="Model\CreeperModel.cs" />
<Compile Include="Model\IModel.cs" />
<Compile Include="Model\ModelCache.cs" />
<Compile Include="Model\ModelPart.cs" />
<Compile Include="Model\PigModel.cs" />
<Compile Include="Model\PlayerModel.cs" />
<Compile Include="Model\SheepModel.cs" />
<Compile Include="Model\SkeletonModel.cs" />
<Compile Include="Model\SpiderModel.cs" />
<Compile Include="Model\ZombieModel.cs" />
<Compile Include="Network\Enums.cs" />
<Compile Include="Network\FastNetReader.cs" />
<Compile Include="Network\FixedBufferStream.cs" />

View file

@ -1,166 +0,0 @@
using OpenTK;
using System;
using System.Drawing;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
namespace ClassicalSharp.Model {
public class BlockModel : IModel {
byte block = (byte)Block.Air;
public BlockModel( Game window ) : base( window ) {
vertices = new VertexPos3fTex2fCol4b[6 * 6];
}
public override float NameYOffset {
get { return blockHeight + 0.075f; }
}
protected override void DrawPlayerModel( Player player, PlayerRenderer renderer ) {
graphics.Texturing = true;
graphics.AlphaTest = true;
block = Byte.Parse( player.ModelName );
if( block == 0 ) {
blockHeight = 1;
return;
}
graphics.Bind2DTexture( window.TerrainAtlasTexId );
blockHeight = window.BlockInfo.BlockHeight( block );
atlas = window.TerrainAtlas;
BlockInfo = window.BlockInfo;
index = 0;
if( BlockInfo.IsSprite( block ) ) {
DrawSprite();
graphics.DrawVertices( DrawMode.Triangles, vertices, 6 * 2 );
} else {
DrawTopFace();
DrawLeftFace();
DrawRightFace();
DrawFrontFace();
DrawBackFace();
DrawBottomFace();
graphics.DrawVertices( DrawMode.Triangles, vertices, 6 * 6 );
}
}
float blockHeight;
TextureAtlas2D atlas;
BlockInfo BlockInfo;
public override void Dispose() {
}
void DrawTopFace() {
int texId = BlockInfo.GetOptimTextureLoc( block, TileSide.Top );
TextureRectangle rec = atlas.GetTexRec( texId );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f + blockHeight, -0.5f, rec.U1, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f + blockHeight, -0.5f, rec.U2, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f + blockHeight, 0.5f, rec.U2, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f + blockHeight, 0.5f, rec.U2, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f + blockHeight, 0.5f, rec.U1, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f + blockHeight, -0.5f, rec.U1, rec.V1, col );
}
void DrawBottomFace() {
int texId = BlockInfo.GetOptimTextureLoc( block, TileSide.Bottom );
TextureRectangle rec = atlas.GetTexRec( texId );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f, -0.5f, rec.U1, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f, -0.5f, rec.U2, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f, 0.5f, rec.U2, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f, 0.5f, rec.U2, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f, 0.5f, rec.U1, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f, -0.5f, rec.U1, rec.V1, col );
}
void DrawBackFace() {
int texId = BlockInfo.GetOptimTextureLoc( block, TileSide.Back );
TextureRectangle rec = atlas.GetTexRec( texId );
if( blockHeight != 1 ) {
rec.V2 = rec.V1 + blockHeight * atlas.invVerElementSize;
}
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f, 0.5f, rec.U1, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f + blockHeight, 0.5f, rec.U1, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f + blockHeight, 0.5f, rec.U2, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f + blockHeight, 0.5f, rec.U2, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f, 0.5f, rec.U2, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f, 0.5f, rec.U1, rec.V2, col );
}
void DrawFrontFace() {
int texId = BlockInfo.GetOptimTextureLoc( block, TileSide.Front );
TextureRectangle rec = atlas.GetTexRec( texId );
if( blockHeight != 1 ) {
rec.V2 = rec.V1 + blockHeight * atlas.invVerElementSize;
}
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f, -0.5f, rec.U2, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f + blockHeight, -0.5f, rec.U2, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f + blockHeight, -0.5f, rec.U1, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f + blockHeight, -0.5f, rec.U1, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f, -0.5f, rec.U1, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f, -0.5f, rec.U2, rec.V2, col );
}
void DrawLeftFace() {
int texId = BlockInfo.GetOptimTextureLoc( block, TileSide.Left );
TextureRectangle rec = atlas.GetTexRec( texId );
if( blockHeight != 1 ) {
rec.V2 = rec.V1 + blockHeight * atlas.invVerElementSize;
}
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f, -0.5f, rec.U1, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f + blockHeight, -0.5f, rec.U1, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f + blockHeight, 0.5f, rec.U2, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f + blockHeight, 0.5f, rec.U2, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f, 0.5f, rec.U2, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f, -0.5f, rec.U1, rec.V2, col );
}
void DrawRightFace() {
int texId = BlockInfo.GetOptimTextureLoc( block, TileSide.Right );
TextureRectangle rec = atlas.GetTexRec( texId );
if( blockHeight != 1 ) {
rec.V2 = rec.V1 + blockHeight * atlas.invVerElementSize;
}
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f, -0.5f, rec.U2, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f + blockHeight, -0.5f, rec.U2, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f + blockHeight, 0.5f, rec.U1, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f + blockHeight, 0.5f, rec.U1, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f, 0.5f, rec.U1, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f, -0.5f, rec.U2, rec.V2, col );
}
void DrawSprite() {
int texId = BlockInfo.GetOptimTextureLoc( block, TileSide.Right );
TextureRectangle rec = atlas.GetTexRec( texId );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f, 0f, rec.U2, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f + blockHeight, 0f, rec.U2, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f + blockHeight, 0f, rec.U1, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f + blockHeight, 0f, rec.U1, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0.5f, 0f, 0f, rec.U1, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( -0.5f, 0f, 0f, rec.U2, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0f, 0f, -0.5f, rec.U1, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0f, 0f + blockHeight, -0.5f, rec.U1, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0f, 0f + blockHeight, 0.5f, rec.U2, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0f, 0f + blockHeight, 0.5f, rec.U2, rec.V1, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0f, 0f, 0.5f, rec.U2, rec.V2, col );
vertices[index++] = new VertexPos3fTex2fCol4b( 0f, 0f, -0.5f, rec.U1, rec.V2, col );
}
}
}

View file

@ -1,97 +0,0 @@
using OpenTK;
using System;
using System.Drawing;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
namespace ClassicalSharp.Model {
public class ChickenModel : IModel {
ModelSet Set;
public ChickenModel( Game window ) : base( window ) {
vertices = new VertexPos3fTex2fCol4b[6 * 6];
Set = new ModelSet();
Set.Head = MakeHead();
Set.Head2 = MakeHead2(); // TODO: Find a more appropriate name.
Set.Head3 = MakeHead3();
Set.Torso = MakeTorso();
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" );
}
ModelPart MakeHead() {
return MakePart( 0, 0, 3, 6, 4, 3, 4, 6, -0.125f, 0.125f, 0.5625f, 0.9375f, -0.375f, -0.1875f, false );
}
ModelPart MakeHead2() {
return MakePart( 14, 4, 2, 2, 2, 2, 2, 2, -0.0625f, 0.0625f, 0.5625f, 0.6875f, -0.4375f, -0.3125f, false );
}
ModelPart MakeHead3() {
return MakePart( 14, 0, 2, 2, 4, 2, 4, 2, -0.125f, 0.125f, 0.6875f, 0.8125f, -0.5f, -0.375f, false );
}
ModelPart MakeTorso() {
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 ) {
index = 0;
const float y1 = 0f, y2 = 0.3125f, z2 = 0.0625f, z1 = -0.125f;
YPlane( 32, 0, 3, 3, x2, x1, z1, z2, y1, false ); // bottom feet
ZPlane( 36, 3, 1, 5, legX1, legX2, y1, y2, z2, false ); // vertical part of leg
return new ModelPart( vertices, 2 * 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;
DrawRotate( 0, 0.5625f, -0.1875f, -pitch, 0, 0, Set.Head );
DrawRotate( 0, 0.5625f, -0.1875f, -pitch, 0, 0, Set.Head2 );
DrawRotate( 0, 0.5625f, -0.1875f, -pitch, 0, 0, Set.Head3 );
Set.Torso.Render();
DrawRotate( 0, 0.3125f, 0.0625f, leftLegXRot, 0, 0, Set.LeftLeg );
DrawRotate( 0, 0.3125f, 0.0625f, rightLegXRot, 0, 0, Set.RightLeg );
DrawRotate( -0.1875f, 0.6875f, 0, 0, 0, -Math.Abs( leftArmXRot ), Set.LeftWing );
DrawRotate( 0.1875f, 0.6875f, 0, 0, 0, Math.Abs( rightArmXRot ), Set.RightWing );
}
public override void Dispose() {
Set.Dispose();
graphics.DeleteTexture( DefaultSkinTextureId );
}
class ModelSet {
public ModelPart Head, Head2, Head3, Torso, LeftLeg, RightLeg, LeftWing, RightWing;
public void Dispose() {
RightLeg.Dispose();
LeftLeg.Dispose();
Torso.Dispose();
Head.Dispose();
Head2.Dispose();
Head3.Dispose();
LeftWing.Dispose();
RightWing.Dispose();
}
}
}
}

View file

@ -1,75 +0,0 @@
using OpenTK;
using System;
using System.Drawing;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
namespace ClassicalSharp.Model {
public class CreeperModel : IModel {
ModelSet Set;
public CreeperModel( Game window ) : base( window ) {
vertices = new VertexPos3fTex2fCol4b[6 * 6];
Set = new ModelSet();
Set.Head = MakeHead();
Set.Torso = MakeTorso();
Set.LeftLegFront = MakeLeg( -0.25f, 0, -0.375f, -0.125f );
Set.RightLegFront = MakeLeg( 0, 0.25f, -0.375f, -0.125f );
Set.LeftLegBack = MakeLeg( -0.25f, 0, 0.125f, 0.375f );
Set.RightLegBack = MakeLeg( 0, 0.25f, 0.125f, 0.375f );
vertices = null;
DefaultSkinTextureId = graphics.LoadTexture( "creeper.png" );
}
ModelPart MakeHead() {
return MakePart( 0, 0, 8, 8, 8, 8, 8, 8, -0.25f, 0.25f, 1.125f, 1.625f, -0.25f, 0.25f, false );
}
ModelPart MakeTorso() {
return MakePart( 16, 16, 4, 12, 8, 4, 8, 12, -0.25f, 0.25f, 0.375f, 1.125f, -0.125f, 0.125f, false );
}
ModelPart MakeLeg( float x1, float x2, float z1, float z2 ) {
return MakePart( 0, 16, 4, 6, 4, 4, 4, 6, x1, x2, 0f, 0.375f, z1, z2, false );
}
public override float NameYOffset {
get { return 1.7f; }
}
protected override void DrawPlayerModel( Player player, PlayerRenderer renderer ) {
graphics.Texturing = true;
int texId = DefaultSkinTextureId;
graphics.Bind2DTexture( texId );
DrawRotate( 0, 1.125f, 0, -pitch, 0, 0, Set.Head );
Set.Torso.Render();
DrawRotate( 0, 0.375f, -0.125f, leftLegXRot, 0, 0, Set.LeftLegFront );
DrawRotate( 0, 0.375f, -0.125f, rightLegXRot, 0, 0, Set.RightLegFront );
DrawRotate( 0, 0.375f, 0.125f, rightLegXRot, 0, 0, Set.LeftLegBack );
DrawRotate( 0, 0.375f, 0.125f, leftLegXRot, 0, 0, Set.RightLegBack );
graphics.AlphaTest = true;
}
public override void Dispose() {
Set.Dispose();
graphics.DeleteTexture( DefaultSkinTextureId );
}
class ModelSet {
public ModelPart Head, Torso, LeftLegFront, RightLegFront, LeftLegBack, RightLegBack;
public void Dispose() {
RightLegFront.Dispose();
LeftLegFront.Dispose();
RightLegBack.Dispose();
LeftLegBack.Dispose();
Torso.Dispose();
Head.Dispose();
}
}
}
}

View file

@ -13,44 +13,7 @@ namespace ClassicalSharp.Model {
Dictionary<string, IModel> cache = new Dictionary<string, IModel>();
public IModel GetModel( string modelName ) {
IModel model;
byte blockId;
if( Byte.TryParse( modelName, out blockId ) ) {
if( !cache.TryGetValue( "block", out model ) ) {
model = new BlockModel( window );
cache["block"] = model;
}
return model;
} else {
if( !cache.TryGetValue( modelName, out model ) ) {
model = InitModel( modelName );
if( model != null ) {
cache[modelName] = model;
} else {
model = cache["humanoid"]; // fallback to default
}
}
return model;
}
}
IModel InitModel( string modelName ) {
if( modelName == "chicken" ) {
return new ChickenModel( window );
} else if( modelName == "creeper" ) {
return new CreeperModel( window );
} else if( modelName == "pig" ) {
return new PigModel( window );
} else if( modelName == "sheep" ) {
return new SheepModel( window );
} else if( modelName == "skeleton" ) {
return new SkeletonModel( window );
} else if( modelName == "spider" ) {
return new SpiderModel( window );
} else if( modelName == "zombie" ) {
return new ZombieModel( window );
}
return null;
return cache["humanoid"];
}
public void Dispose() {

View file

@ -1,75 +0,0 @@
using OpenTK;
using System;
using System.Drawing;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
namespace ClassicalSharp.Model {
public class PigModel : IModel {
ModelSet Set;
public PigModel( Game window ) : base( window ) {
vertices = new VertexPos3fTex2fCol4b[6 * 6];
Set = new ModelSet();
Set.Head = MakeHead();
Set.Torso = MakeTorso();
Set.LeftLegFront = MakeLeg( -0.3125f, -0.0625f, -0.4375f, -0.1875f );
Set.RightLegFront = MakeLeg( 0.0625f, 0.3125f, -0.4375f, -0.1875f );
Set.LeftLegBack = MakeLeg( -0.3125f, -0.0625f, 0.3125f, 0.5625f );
Set.RightLegBack = MakeLeg( 0.0625f, 0.3125f, 0.3125f, 0.5625f );
vertices = null;
DefaultSkinTextureId = graphics.LoadTexture( "pig.png" );
}
ModelPart MakeHead() {
return MakePart( 0, 0, 8, 8, 8, 8, 8, 8, -0.25f, 0.25f, 0.5f, 1f, -0.875f, -0.375f, false );
}
ModelPart MakeTorso() {
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 ) {
return MakePart( 0, 16, 4, 6, 4, 4, 4, 6, x1, x2, 0f, 0.375f, z1, z2, false );
}
public override float NameYOffset {
get { return 1.075f; }
}
protected override void DrawPlayerModel( Player player, PlayerRenderer renderer ) {
graphics.Texturing = true;
int texId = DefaultSkinTextureId;
graphics.Bind2DTexture( texId );
DrawRotate( 0, 0.75f, -0.375f, -pitch, 0, 0, Set.Head );
Set.Torso.Render();
DrawRotate( 0, 0.375f, -0.3125f, leftLegXRot, 0, 0, Set.LeftLegFront );
DrawRotate( 0, 0.375f, -0.3125f, rightLegXRot, 0, 0, Set.RightLegFront );
DrawRotate( 0, 0.375f, 0.4375f, rightLegXRot, 0, 0, Set.LeftLegBack );
DrawRotate( 0, 0.375f, 0.4375f, leftLegXRot, 0, 0, Set.RightLegBack );
graphics.AlphaTest = true;
}
public override void Dispose() {
Set.Dispose();
graphics.DeleteTexture( DefaultSkinTextureId );
}
class ModelSet {
public ModelPart Head, Torso, LeftLegFront, RightLegFront, LeftLegBack, RightLegBack;
public void Dispose() {
RightLegFront.Dispose();
LeftLegFront.Dispose();
RightLegBack.Dispose();
LeftLegBack.Dispose();
Torso.Dispose();
Head.Dispose();
}
}
}
}

View file

@ -1,125 +0,0 @@
using OpenTK;
using System;
using System.Drawing;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
namespace ClassicalSharp.Model {
public class SheepModel : IModel {
ModelSet Set;
public bool Fur = true;
int furTextureId;
public SheepModel( Game window ) : base( window ) {
vertices = new VertexPos3fTex2fCol4b[6 * 6];
Set = new ModelSet( Fur );
Set.Head = MakeHead();
Set.Torso = MakeTorso();
Set.LeftLegFront = MakeLeg( -0.3125f, -0.0625f, -0.4375f, -0.1875f );
Set.RightLegFront = MakeLeg( 0.0625f, 0.3125f, -0.4375f, -0.1875f );
Set.LeftLegBack = MakeLeg( -0.3125f, -0.0625f, 0.3125f, 0.5625f );
Set.RightLegBack = MakeLeg( 0.0625f, 0.3125f, 0.3125f, 0.5625f );
if( Fur ) {
Set.FurHead = MakeFurHead();
Set.FurTorso = MakeFurTorso();
Set.FurLeftLegFront = MakeFurLeg( -0.34375f, -0.03125f, -0.46875f, -0.15625f );
Set.FurRightLegFront = MakeFurLeg( 0.03125f, 0.34375f, -0.46875f, -0.15625f );
Set.FurLeftLegBack = MakeFurLeg( -0.34375f, -0.03125f, 0.28125f, 0.59375f );
Set.FurRightLegBack = MakeFurLeg( 0.03125f, 0.34375f, 0.28125f, 0.59375f );
}
vertices = null;
DefaultSkinTextureId = graphics.LoadTexture( "sheep.png" );
furTextureId = graphics.LoadTexture( "sheep_fur.png" );
}
ModelPart MakeHead() {
return MakePart( 0, 0, 8, 6, 6, 8, 6, 6, -0.1875f, 0.1875f, 1f, 1.375f, -0.875f, -0.375f, false );
}
ModelPart MakeTorso() {
return MakeRotatedPart( 28, 8, 6, 16, 8, 6, 8, 16, -0.25f, 0.25f, 0.75f, 1.125f, -0.5f, 0.5f, false );
}
ModelPart MakeFurHead() {
return MakePart( 0, 0, 6, 6, 6, 6, 6, 6, -0.21875f, 0.21875f, 0.96875f, 1.40625f, -0.78125f, -0.34375f, false );
}
ModelPart MakeFurTorso() {
return MakeRotatedPart( 28, 8, 6, 16, 8, 6, 8, 16, -0.375f, 0.375f, 0.65625f, 1.21875f, -0.625f, 0.625f, false );
}
ModelPart MakeLeg( float x1, float x2, float z1, float z2 ) {
return MakePart( 0, 16, 4, 12, 4, 4, 4, 12, x1, x2, 0f, 0.75f, z1, z2, false );
}
ModelPart MakeFurLeg( float x1, float x2, float z1, float z2 ) {
return MakePart( 0, 16, 4, 6, 4, 4, 4, 6, x1, x2, 0.34375f, 0.78125f, z1, z2, false );
}
public override float NameYOffset {
get { return 1.075f; }
}
protected override void DrawPlayerModel( Player player, PlayerRenderer renderer ) {
graphics.Texturing = true;
int texId = DefaultSkinTextureId;
graphics.Bind2DTexture( texId );
DrawRotate( 0, 1.125f, -0.5f, -pitch, 0, 0, Set.Head );
Set.Torso.Render();
DrawRotate( 0, 0.75f, -0.3125f, leftLegXRot, 0, 0, Set.LeftLegFront );
DrawRotate( 0, 0.75f, -0.3125f, rightLegXRot, 0, 0, Set.RightLegFront );
DrawRotate( 0, 0.75f, 0.4375f, rightLegXRot, 0, 0, Set.LeftLegBack );
DrawRotate( 0, 0.75f, 0.4375f, leftLegXRot, 0, 0, Set.RightLegBack );
graphics.AlphaTest = true;
if( Fur ) {
graphics.Bind2DTexture( furTextureId );
Set.FurTorso.Render();
DrawRotate( 0, 1.125f, -0.5f, -pitch, 0, 0, Set.FurHead );
DrawRotate( 0, 0.75f, -0.3125f, leftLegXRot, 0, 0, Set.FurLeftLegFront );
DrawRotate( 0, 0.75f, -0.3125f, rightLegXRot, 0, 0, Set.FurRightLegFront );
DrawRotate( 0, 0.75f, 0.4375f, rightLegXRot, 0, 0, Set.FurLeftLegBack );
DrawRotate( 0, 0.75f, 0.4375f, leftLegXRot, 0, 0, Set.FurRightLegBack );
}
}
public override void Dispose() {
Set.Dispose();
graphics.DeleteTexture( DefaultSkinTextureId );
if( Fur ) {
graphics.DeleteTexture( furTextureId );
}
}
class ModelSet {
bool fur;
public ModelPart Head, Torso, LeftLegFront, RightLegFront, LeftLegBack, RightLegBack;
public ModelPart FurHead, FurTorso, FurLeftLegFront, FurRightLegFront,
FurLeftLegBack, FurRightLegBack;
public ModelSet( bool fur ) {
this.fur = fur;
}
public void Dispose() {
RightLegFront.Dispose();
LeftLegFront.Dispose();
RightLegBack.Dispose();
LeftLegBack.Dispose();
Torso.Dispose();
Head.Dispose();
if( fur ) {
FurHead.Dispose();
FurTorso.Dispose();
FurLeftLegBack.Dispose();
FurLeftLegFront.Dispose();
FurRightLegBack.Dispose();
FurRightLegFront.Dispose();
}
}
}
}
}

View file

@ -1,87 +0,0 @@
using OpenTK;
using System;
using System.Drawing;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
namespace ClassicalSharp.Model {
public class SkeletonModel : IModel {
ModelSet Set;
public SkeletonModel( Game window ) : base( window ) {
vertices = new VertexPos3fTex2fCol4b[6 * 6];
Set = new ModelSet();
Set.Head = MakeHead();
Set.Torso = MakeTorso();
Set.LeftLeg = MakeLeftLeg( 0.1875f, 0.0625f );
Set.RightLeg = MakeRightLeg( 0.0625f, 0.1875f );
Set.LeftArm = MakeLeftArm( 0.375f, 0.25f );
Set.RightArm = MakeRightArm( 0.25f, 0.375f );
vertices = null;
DefaultSkinTextureId = graphics.LoadTexture( "skeleton.png" );
}
ModelPart MakeLeftArm( float x1, float x2 ) {
return MakePart( 40, 16, 2, 12, 2, 2, 2, 12, -x2, -x1, 0.75f, 1.5f, -0.0625f, 0.0625f, false );
}
ModelPart MakeRightArm( float x1, float x2 ) {
return MakePart( 40, 16, 2, 12, 2, 2, 2, 12, x1, x2, 0.75f, 1.5f, -0.0625f, 0.0625f, false );
}
ModelPart MakeHead() {
return MakePart( 0, 0, 8, 8, 8, 8, 8, 8, -0.25f, 0.25f, 1.5f, 2f, -0.25f, 0.25f, false );
}
ModelPart MakeTorso() {
return MakePart( 16, 16, 4, 12, 8, 4, 8, 12, -0.25f, 0.25f, 0.75f, 1.5f, -0.125f, 0.125f, false );
}
ModelPart MakeLeftLeg( float x1, float x2 ) {
return MakePart( 0, 16, 2, 12, 2, 2, 2, 12, -x2, -x1, 0f, 0.75f, -0.0625f, 0.0625f, false );
}
ModelPart MakeRightLeg( float x1, float x2 ) {
return MakePart( 0, 16, 2, 12, 2, 2, 2, 12, x1, x2, 0f, 0.75f, -0.0625f, 0.0625f, false );
}
public override float NameYOffset {
get { return 2.075f; }
}
protected override void DrawPlayerModel( Player player, PlayerRenderer renderer ) {
graphics.Texturing = true;
graphics.AlphaTest = true;
int texId = DefaultSkinTextureId;
graphics.Bind2DTexture( texId );
DrawRotate( 0, 1.5f, 0, -pitch, 0, 0, Set.Head );
Set.Torso.Render();
DrawRotate( 0, 0.75f, 0, leftLegXRot, 0, 0, Set.LeftLeg );
DrawRotate( 0, 0.75f, 0, rightLegXRot, 0, 0, Set.RightLeg );
DrawRotate( 0, 1.375f, 0, 90f, 0, leftArmZRot, Set.LeftArm );
DrawRotate( 0, 1.375f, 0, 90f, 0, rightArmZRot, Set.RightArm );
}
public override void Dispose() {
Set.Dispose();
graphics.DeleteTexture( DefaultSkinTextureId );
}
class ModelSet {
public ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm;
public void Dispose() {
RightArm.Dispose();
LeftArm.Dispose();
RightLeg.Dispose();
LeftLeg.Dispose();
Torso.Dispose();
Head.Dispose();
}
}
}
}

View file

@ -1,82 +0,0 @@
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.LeftLeg = MakeLeg( -1.1875f, -0.1875f );
Set.RightLeg = MakeLeg( 0.1875f, 1.1875f );
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() {
return MakePart( 0, 12, 12, 8, 10, 12, 10, 8, -0.3125f, 0.3125f, 0.25f, 0.75f, 0.1875f, 0.9375f, false );
}
ModelPart MakeLeg( float x1, float x2 ) {
return MakePart( 18, 0, 2, 2, 16, 2, 16, 2, x1, x2, 0.4375f, 0.5625f, -0.0625f, 0.0625f, false );
}
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;
DrawRotate( 0, 0.5f, -0.1875f, -pitch, 0, 0, Set.Head );
Set.Link.Render();
Set.End.Render();
DrawRotate( -0.1875f, 0.5f, 0, 0, 45f, 22.5f, Set.LeftLeg );
DrawRotate( -0.1875f, 0.5f, 0, 0, 22.5f, 22.5f, Set.LeftLeg );
DrawRotate( -0.1875f, 0.5f, 0, 0, -22.5f, 22.5f, Set.LeftLeg );
DrawRotate( -0.1875f, 0.5f, 0, 0, -45f, 22.5f, Set.LeftLeg );
DrawRotate( 0.1875f, 0.5f, 0, 0, -45f, -22.5f, Set.RightLeg );
DrawRotate( 0.1875f, 0.5f, 0, 0, -22.5f, -22.5f, Set.RightLeg );
DrawRotate( 0.1875f, 0.5f, 0, 0, 22.5f, -22.5f, Set.RightLeg );
DrawRotate( 0.1875f, 0.5f, 0, leftLegXRot, 45f, -22.5f, Set.RightLeg );
}
public override void Dispose() {
Set.Dispose();
graphics.DeleteTexture( DefaultSkinTextureId );
}
class ModelSet {
public ModelPart Head, Link, End, LeftLeg, RightLeg;
public void Dispose() {
RightLeg.Dispose();
LeftLeg.Dispose();
End.Dispose();
Head.Dispose();
Link.Dispose();
}
}
}
}

View file

@ -1,87 +0,0 @@
using OpenTK;
using System;
using System.Drawing;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
namespace ClassicalSharp.Model {
public class ZombieModel : IModel {
ModelSet Set;
public ZombieModel( Game window ) : base( window ) {
vertices = new VertexPos3fTex2fCol4b[6 * 6];
Set = new ModelSet();
Set.Head = MakeHead();
Set.Torso = MakeTorso();
Set.LeftLeg = MakeLeftLeg( 0.25f, 0f );
Set.RightLeg = MakeRightLeg( 0, 0.25f );
Set.LeftArm = MakeLeftArm( 0.5f, 0.25f );
Set.RightArm = MakeRightArm( 0.25f, 0.5f );
vertices = null;
DefaultSkinTextureId = graphics.LoadTexture( "zombie.png" );
}
ModelPart MakeLeftArm( float x1, float x2 ) {
return MakePart( 40, 16, 4, 12, 4, 4, 4, 12, -x2, -x1, 0.75f, 1.5f, -0.125f, 0.125f, false );
}
ModelPart MakeRightArm( float x1, float x2 ) {
return MakePart( 40, 16, 4, 12, 4, 4, 4, 12, x1, x2, 0.75f, 1.5f, -0.125f, 0.125f, false );
}
ModelPart MakeHead() {
return MakePart( 0, 0, 8, 8, 8, 8, 8, 8, -0.25f, 0.25f, 1.5f, 2f, -0.25f, 0.25f, false );
}
ModelPart MakeTorso() {
return MakePart( 16, 16, 4, 12, 8, 4, 8, 12, -0.25f, 0.25f, 0.75f, 1.5f, -0.125f, 0.125f, false );
}
ModelPart MakeLeftLeg( float x1, float x2 ) {
return MakePart( 0, 16, 4, 12, 4, 4, 4, 12, -x2, -x1, 0f, 0.75f, -0.125f, 0.125f, false );
}
ModelPart MakeRightLeg( float x1, float x2 ) {
return MakePart( 0, 16, 4, 12, 4, 4, 4, 12, x1, x2, 0f, 0.75f, -0.125f, 0.125f, false );
}
public override float NameYOffset {
get { return 2.075f; }
}
protected override void DrawPlayerModel( Player player, PlayerRenderer renderer ) {
graphics.Texturing = true;
int texId = DefaultSkinTextureId;
graphics.Bind2DTexture( texId );
DrawRotate( 0, 1.5f, 0, -pitch, 0, 0, Set.Head );
Set.Torso.Render();
DrawRotate( 0, 0.75f, 0, leftLegXRot, 0, 0, Set.LeftLeg );
DrawRotate( 0, 0.75f, 0, rightLegXRot, 0, 0, Set.RightLeg );
DrawRotate( 0, 1.375f, 0, 90f, 0, leftArmZRot, Set.LeftArm );
DrawRotate( 0, 1.375f, 0, 90f, 0, rightArmZRot, Set.RightArm );
graphics.AlphaTest = true;
}
public override void Dispose() {
Set.Dispose();
graphics.DeleteTexture( DefaultSkinTextureId );
}
class ModelSet {
public ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm;
public void Dispose() {
RightArm.Dispose();
LeftArm.Dispose();
RightLeg.Dispose();
LeftLeg.Dispose();
Torso.Dispose();
Head.Dispose();
}
}
}
}

View file

@ -151,7 +151,7 @@ namespace ClassicalSharp {
static string[] clientExtensions = new string[] {
"EmoteFix", "ClickDistance", "HeldBlock", "BlockPermissions",
"MessageTypes", "CustomBlocks", "EnvColors",
"HackControl", "EnvMapAppearance", "ExtPlayerList", "ChangeModel",
"HackControl", "EnvMapAppearance", "ExtPlayerList",
};
@ -605,16 +605,6 @@ namespace ClassicalSharp {
Window.RaiseBlockPermissionsChanged();
} break;
case PacketId.CpeChangeModel:
{
byte playerId = reader.ReadUInt8();
string modelName = reader.ReadString().ToLowerInvariant();
Player player = playerId == 0xFF ? Window.LocalPlayer : Window.NetPlayers[playerId];
if( player != null ) {
player.SetModel( modelName );
}
} break;
case PacketId.CpeEnvSetMapApperance:
{
string url = reader.ReadString();