mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Add ability to change entity textures with local texture packs.
This commit is contained in:
parent
670a887218
commit
5a8ec25957
@ -17,7 +17,8 @@ namespace ClassicalSharp.Model {
|
|||||||
LeftWing = MakeWing( -0.25f, -0.1875f );
|
LeftWing = MakeWing( -0.25f, -0.1875f );
|
||||||
RightWing = MakeWing( 0.1875f, 0.25f );
|
RightWing = MakeWing( 0.1875f, 0.25f );
|
||||||
|
|
||||||
DefaultTexId = graphics.CreateTexture( "chicken.png" );
|
if( cache.ChickenTexId <= 0 )
|
||||||
|
cache.ChickenTexId = graphics.CreateTexture( "chicken.png" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelPart MakeHead() {
|
ModelPart MakeHead() {
|
||||||
@ -61,7 +62,7 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
protected override void DrawPlayerModel( Player p ) {
|
protected override void DrawPlayerModel( Player p ) {
|
||||||
graphics.Texturing = true;
|
graphics.Texturing = true;
|
||||||
int texId = p.MobTextureId <= 0 ? DefaultTexId : p.MobTextureId;
|
int texId = p.MobTextureId <= 0 ? cache.ChickenTexId : p.MobTextureId;
|
||||||
graphics.BindTexture( texId );
|
graphics.BindTexture( texId );
|
||||||
graphics.AlphaTest = true;
|
graphics.AlphaTest = true;
|
||||||
|
|
||||||
@ -75,10 +76,6 @@ namespace ClassicalSharp.Model {
|
|||||||
DrawRotate( 0.1875f, 0.6875f, 0, 0, 0, Math.Abs( p.rightArmXRot ), RightWing );
|
DrawRotate( 0.1875f, 0.6875f, 0, 0, 0, Math.Abs( p.rightArmXRot ), RightWing );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() {
|
|
||||||
graphics.DeleteTexture( ref DefaultTexId );
|
|
||||||
}
|
|
||||||
|
|
||||||
ModelPart Head, Head2, Head3, Torso, LeftLeg, RightLeg, LeftWing, RightWing;
|
ModelPart Head, Head2, Head3, Torso, LeftLeg, RightLeg, LeftWing, RightWing;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,8 @@ namespace ClassicalSharp.Model {
|
|||||||
LeftLegBack = MakeLeg( -0.25f, 0, 0.125f, 0.375f );
|
LeftLegBack = MakeLeg( -0.25f, 0, 0.125f, 0.375f );
|
||||||
RightLegBack = MakeLeg( 0, 0.25f, 0.125f, 0.375f );
|
RightLegBack = MakeLeg( 0, 0.25f, 0.125f, 0.375f );
|
||||||
|
|
||||||
DefaultTexId = graphics.CreateTexture( "creeper.png" );
|
if( cache.CreeperTexId <= 0 )
|
||||||
|
cache.CreeperTexId = graphics.CreateTexture( "creeper.png" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelPart MakeHead() {
|
ModelPart MakeHead() {
|
||||||
@ -44,7 +45,7 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
protected override void DrawPlayerModel( Player p ) {
|
protected override void DrawPlayerModel( Player p ) {
|
||||||
graphics.Texturing = true;
|
graphics.Texturing = true;
|
||||||
int texId = p.MobTextureId <= 0 ? DefaultTexId : p.MobTextureId;
|
int texId = p.MobTextureId <= 0 ? cache.CreeperTexId : p.MobTextureId;
|
||||||
graphics.BindTexture( texId );
|
graphics.BindTexture( texId );
|
||||||
|
|
||||||
DrawRotate( 0, 1.125f, 0, -p.PitchRadians, 0, 0, Head );
|
DrawRotate( 0, 1.125f, 0, -p.PitchRadians, 0, 0, Head );
|
||||||
@ -56,10 +57,6 @@ namespace ClassicalSharp.Model {
|
|||||||
graphics.AlphaTest = true;
|
graphics.AlphaTest = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() {
|
|
||||||
graphics.DeleteTexture( ref DefaultTexId );
|
|
||||||
}
|
|
||||||
|
|
||||||
ModelPart Head, Torso, LeftLegFront, RightLegFront, LeftLegBack, RightLegBack;
|
ModelPart Head, Torso, LeftLegFront, RightLegFront, LeftLegBack, RightLegBack;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -42,9 +42,8 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
protected abstract void DrawPlayerModel( Player p );
|
protected abstract void DrawPlayerModel( Player p );
|
||||||
|
|
||||||
public abstract void Dispose();
|
public virtual void Dispose() {
|
||||||
|
}
|
||||||
public int DefaultTexId;
|
|
||||||
|
|
||||||
protected FastColour col;
|
protected FastColour col;
|
||||||
protected VertexPos3fTex2fCol4b[] vertices;
|
protected VertexPos3fTex2fCol4b[] vertices;
|
||||||
|
@ -16,13 +16,15 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
public void InitCache() {
|
public void InitCache() {
|
||||||
vertices = new VertexPos3fTex2fCol4b[384];
|
vertices = new VertexPos3fTex2fCol4b[384];
|
||||||
vb = game.Graphics.CreateDynamicVb( VertexFormat.Pos3fTex2fCol4b, vertices.Length );
|
vb = api.CreateDynamicVb( VertexFormat.Pos3fTex2fCol4b, vertices.Length );
|
||||||
cache["humanoid"] = new PlayerModel( game );
|
cache["humanoid"] = new PlayerModel( game );
|
||||||
}
|
}
|
||||||
|
|
||||||
internal int vb;
|
internal int vb;
|
||||||
internal VertexPos3fTex2fCol4b[] vertices;
|
internal VertexPos3fTex2fCol4b[] vertices;
|
||||||
Dictionary<string, IModel> cache = new Dictionary<string, IModel>();
|
Dictionary<string, IModel> cache = new Dictionary<string, IModel>();
|
||||||
|
internal int ChickenTexId, CreeperTexId, PigTexId, SheepTexId,
|
||||||
|
SkeletonTexId, SpiderTexId, ZombieTexId, SheepFurTexId, HumanoidTexId;
|
||||||
|
|
||||||
public IModel GetModel( string modelName ) {
|
public IModel GetModel( string modelName ) {
|
||||||
IModel model;
|
IModel model;
|
||||||
@ -72,7 +74,16 @@ namespace ClassicalSharp.Model {
|
|||||||
foreach( var entry in cache ) {
|
foreach( var entry in cache ) {
|
||||||
entry.Value.Dispose();
|
entry.Value.Dispose();
|
||||||
}
|
}
|
||||||
game.Graphics.DeleteDynamicVb( vb );
|
api.DeleteDynamicVb( vb );
|
||||||
|
api.DeleteTexture( ref ChickenTexId );
|
||||||
|
api.DeleteTexture( ref CreeperTexId );
|
||||||
|
api.DeleteTexture( ref PigTexId );
|
||||||
|
api.DeleteTexture( ref SheepTexId );
|
||||||
|
api.DeleteTexture( ref SkeletonTexId );
|
||||||
|
api.DeleteTexture( ref SpiderTexId );
|
||||||
|
api.DeleteTexture( ref ZombieTexId );
|
||||||
|
api.DeleteTexture( ref SheepFurTexId );
|
||||||
|
api.DeleteTexture( ref HumanoidTexId );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,8 @@ namespace ClassicalSharp.Model {
|
|||||||
LeftLegBack = MakeLeg( -0.3125f, -0.0625f, 0.3125f, 0.5625f );
|
LeftLegBack = MakeLeg( -0.3125f, -0.0625f, 0.3125f, 0.5625f );
|
||||||
RightLegBack = MakeLeg( 0.0625f, 0.3125f, 0.3125f, 0.5625f );
|
RightLegBack = MakeLeg( 0.0625f, 0.3125f, 0.3125f, 0.5625f );
|
||||||
|
|
||||||
DefaultTexId = graphics.CreateTexture( "pig.png" );
|
if( cache.PigTexId <= 0 )
|
||||||
|
cache.PigTexId = graphics.CreateTexture( "pig.png" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelPart MakeHead() {
|
ModelPart MakeHead() {
|
||||||
@ -44,7 +45,7 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
protected override void DrawPlayerModel( Player p ) {
|
protected override void DrawPlayerModel( Player p ) {
|
||||||
graphics.Texturing = true;
|
graphics.Texturing = true;
|
||||||
int texId = p.MobTextureId <= 0 ? DefaultTexId : p.MobTextureId;
|
int texId = p.MobTextureId <= 0 ? cache.PigTexId : p.MobTextureId;
|
||||||
graphics.BindTexture( texId );
|
graphics.BindTexture( texId );
|
||||||
|
|
||||||
DrawRotate( 0, 0.75f, -0.375f, -p.PitchRadians, 0, 0, Head );
|
DrawRotate( 0, 0.75f, -0.375f, -p.PitchRadians, 0, 0, Head );
|
||||||
@ -56,10 +57,6 @@ namespace ClassicalSharp.Model {
|
|||||||
graphics.AlphaTest = true;
|
graphics.AlphaTest = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() {
|
|
||||||
graphics.DeleteTexture( ref DefaultTexId );
|
|
||||||
}
|
|
||||||
|
|
||||||
ModelPart Head, Torso, LeftLegFront, RightLegFront, LeftLegBack, RightLegBack;
|
ModelPart Head, Torso, LeftLegFront, RightLegFront, LeftLegBack, RightLegBack;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,7 +39,7 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
using( Bitmap bmp = new Bitmap( "char.png" ) ) {
|
using( Bitmap bmp = new Bitmap( "char.png" ) ) {
|
||||||
window.DefaultPlayerSkinType = Utils.GetSkinType( bmp );
|
window.DefaultPlayerSkinType = Utils.GetSkinType( bmp );
|
||||||
DefaultTexId = graphics.CreateTexture( bmp );
|
cache.HumanoidTexId = graphics.CreateTexture( bmp );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ namespace ClassicalSharp.Model {
|
|||||||
ModelSet model;
|
ModelSet model;
|
||||||
protected override void DrawPlayerModel( Player p ) {
|
protected override void DrawPlayerModel( Player p ) {
|
||||||
graphics.Texturing = true;
|
graphics.Texturing = true;
|
||||||
int texId = p.PlayerTextureId <= 0 ? DefaultTexId : p.PlayerTextureId;
|
int texId = p.PlayerTextureId <= 0 ? cache.HumanoidTexId : p.PlayerTextureId;
|
||||||
graphics.BindTexture( texId );
|
graphics.BindTexture( texId );
|
||||||
|
|
||||||
SkinType skinType = p.SkinType;
|
SkinType skinType = p.SkinType;
|
||||||
@ -104,10 +104,6 @@ namespace ClassicalSharp.Model {
|
|||||||
DrawRotate( 0, 1.4375f, 0, -p.PitchRadians, 0, 0, model.Hat );
|
DrawRotate( 0, 1.4375f, 0, -p.PitchRadians, 0, 0, model.Hat );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() {
|
|
||||||
graphics.DeleteTexture( ref DefaultTexId );
|
|
||||||
}
|
|
||||||
|
|
||||||
class ModelSet {
|
class ModelSet {
|
||||||
|
|
||||||
public ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm, Hat;
|
public ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm, Hat;
|
||||||
|
@ -27,8 +27,10 @@ namespace ClassicalSharp.Model {
|
|||||||
FurRightLegBack = MakeFurLeg( 0.03125f, 0.34375f, 0.28125f, 0.59375f );
|
FurRightLegBack = MakeFurLeg( 0.03125f, 0.34375f, 0.28125f, 0.59375f );
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultTexId = graphics.CreateTexture( "sheep.png" );
|
if( cache.SheepTexId <= 0 )
|
||||||
furTextureId = graphics.CreateTexture( "sheep_fur.png" );
|
cache.SheepTexId = graphics.CreateTexture( "sheep.png" );
|
||||||
|
if( cache.SheepFurTexId <= 0 )
|
||||||
|
cache.SheepFurTexId = graphics.CreateTexture( "sheep_fur.png" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelPart MakeHead() {
|
ModelPart MakeHead() {
|
||||||
@ -69,7 +71,7 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
protected override void DrawPlayerModel( Player p ) {
|
protected override void DrawPlayerModel( Player p ) {
|
||||||
graphics.Texturing = true;
|
graphics.Texturing = true;
|
||||||
int texId = p.MobTextureId <= 0 ? DefaultTexId : p.MobTextureId;
|
int texId = p.MobTextureId <= 0 ? cache.SheepTexId : p.MobTextureId;
|
||||||
graphics.BindTexture( texId );
|
graphics.BindTexture( texId );
|
||||||
|
|
||||||
DrawRotate( 0, 1.125f, -0.5f, -p.PitchRadians, 0, 0, Head );
|
DrawRotate( 0, 1.125f, -0.5f, -p.PitchRadians, 0, 0, Head );
|
||||||
@ -80,7 +82,7 @@ namespace ClassicalSharp.Model {
|
|||||||
DrawRotate( 0, 0.75f, 0.4375f, p.leftLegXRot, 0, 0, RightLegBack );
|
DrawRotate( 0, 0.75f, 0.4375f, p.leftLegXRot, 0, 0, RightLegBack );
|
||||||
graphics.AlphaTest = true;
|
graphics.AlphaTest = true;
|
||||||
if( Fur ) {
|
if( Fur ) {
|
||||||
graphics.BindTexture( furTextureId );
|
graphics.BindTexture( cache.SheepFurTexId );
|
||||||
DrawPart( FurTorso );
|
DrawPart( FurTorso );
|
||||||
DrawRotate( 0, 1.125f, -0.5f, -p.PitchRadians, 0, 0, FurHead );
|
DrawRotate( 0, 1.125f, -0.5f, -p.PitchRadians, 0, 0, FurHead );
|
||||||
DrawRotate( 0, 0.75f, -0.3125f, p.leftLegXRot, 0, 0, FurLeftLegFront );
|
DrawRotate( 0, 0.75f, -0.3125f, p.leftLegXRot, 0, 0, FurLeftLegFront );
|
||||||
@ -90,13 +92,6 @@ namespace ClassicalSharp.Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() {
|
|
||||||
graphics.DeleteTexture( ref DefaultTexId );
|
|
||||||
if( Fur ) {
|
|
||||||
graphics.DeleteTexture( ref furTextureId );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ModelPart Head, Torso, LeftLegFront, RightLegFront, LeftLegBack, RightLegBack;
|
ModelPart Head, Torso, LeftLegFront, RightLegFront, LeftLegBack, RightLegBack;
|
||||||
ModelPart FurHead, FurTorso, FurLeftLegFront, FurRightLegFront, FurLeftLegBack, FurRightLegBack;
|
ModelPart FurHead, FurTorso, FurLeftLegFront, FurRightLegFront, FurLeftLegBack, FurRightLegBack;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using ClassicalSharp.GraphicsAPI;
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
|
||||||
namespace ClassicalSharp.Model {
|
namespace ClassicalSharp.Model {
|
||||||
@ -15,7 +14,8 @@ namespace ClassicalSharp.Model {
|
|||||||
LeftArm = MakeLeftArm( 0.375f, 0.25f );
|
LeftArm = MakeLeftArm( 0.375f, 0.25f );
|
||||||
RightArm = MakeRightArm( 0.25f, 0.375f );
|
RightArm = MakeRightArm( 0.25f, 0.375f );
|
||||||
|
|
||||||
DefaultTexId = graphics.CreateTexture( "skeleton.png" );
|
if( cache.SkeletonTexId <= 0 )
|
||||||
|
cache.SkeletonTexId = graphics.CreateTexture( "skeleton.png" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelPart MakeLeftArm( float x1, float x2 ) {
|
ModelPart MakeLeftArm( float x1, float x2 ) {
|
||||||
@ -57,7 +57,7 @@ namespace ClassicalSharp.Model {
|
|||||||
protected override void DrawPlayerModel( Player p ) {
|
protected override void DrawPlayerModel( Player p ) {
|
||||||
graphics.Texturing = true;
|
graphics.Texturing = true;
|
||||||
graphics.AlphaTest = true;
|
graphics.AlphaTest = true;
|
||||||
int texId = p.MobTextureId <= 0 ? DefaultTexId : p.MobTextureId;
|
int texId = p.MobTextureId <= 0 ? cache.SkeletonTexId : p.MobTextureId;
|
||||||
graphics.BindTexture( texId );
|
graphics.BindTexture( texId );
|
||||||
|
|
||||||
DrawRotate( 0, 1.5f, 0, -p.PitchRadians, 0, 0, Head );
|
DrawRotate( 0, 1.5f, 0, -p.PitchRadians, 0, 0, Head );
|
||||||
@ -65,11 +65,7 @@ namespace ClassicalSharp.Model {
|
|||||||
DrawRotate( 0, 0.75f, 0, p.leftLegXRot, 0, 0, LeftLeg );
|
DrawRotate( 0, 0.75f, 0, p.leftLegXRot, 0, 0, LeftLeg );
|
||||||
DrawRotate( 0, 0.75f, 0, p.rightLegXRot, 0, 0, RightLeg );
|
DrawRotate( 0, 0.75f, 0, p.rightLegXRot, 0, 0, RightLeg );
|
||||||
DrawRotate( 0, 1.375f, 0, (float)Math.PI / 2, 0, p.leftArmZRot, LeftArm );
|
DrawRotate( 0, 1.375f, 0, (float)Math.PI / 2, 0, p.leftArmZRot, LeftArm );
|
||||||
DrawRotate( 0, 1.375f, 0, (float)Math.PI / 2, 0, p.rightArmZRot, RightArm );
|
DrawRotate( 0, 1.375f, 0, (float)Math.PI / 2, 0, p.rightArmZRot, RightArm );
|
||||||
}
|
|
||||||
|
|
||||||
public override void Dispose() {
|
|
||||||
graphics.DeleteTexture( ref DefaultTexId );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm;
|
ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using ClassicalSharp.GraphicsAPI;
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
|
||||||
namespace ClassicalSharp.Model {
|
namespace ClassicalSharp.Model {
|
||||||
@ -14,7 +13,8 @@ namespace ClassicalSharp.Model {
|
|||||||
LeftLeg = MakeLeg( -1.1875f, -0.1875f );
|
LeftLeg = MakeLeg( -1.1875f, -0.1875f );
|
||||||
RightLeg = MakeLeg( 0.1875f, 1.1875f );
|
RightLeg = MakeLeg( 0.1875f, 1.1875f );
|
||||||
|
|
||||||
DefaultTexId = graphics.CreateTexture( "spider.png" );
|
if( cache.SpiderTexId <= 0 )
|
||||||
|
cache.SpiderTexId = graphics.CreateTexture( "spider.png" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelPart MakeHead() {
|
ModelPart MakeHead() {
|
||||||
@ -49,7 +49,7 @@ namespace ClassicalSharp.Model {
|
|||||||
const float eighthPi = (float)( Math.PI / 8 );
|
const float eighthPi = (float)( Math.PI / 8 );
|
||||||
protected override void DrawPlayerModel( Player p ) {
|
protected override void DrawPlayerModel( Player p ) {
|
||||||
graphics.Texturing = true;
|
graphics.Texturing = true;
|
||||||
int texId = p.MobTextureId <= 0 ? DefaultTexId : p.MobTextureId;
|
int texId = p.MobTextureId <= 0 ? cache.SpiderTexId : p.MobTextureId;
|
||||||
graphics.BindTexture( texId );
|
graphics.BindTexture( texId );
|
||||||
graphics.AlphaTest = true;
|
graphics.AlphaTest = true;
|
||||||
|
|
||||||
@ -60,17 +60,13 @@ namespace ClassicalSharp.Model {
|
|||||||
DrawRotate( -0.1875f, 0.5f, 0, 0, quarterPi, eighthPi, LeftLeg );
|
DrawRotate( -0.1875f, 0.5f, 0, 0, quarterPi, eighthPi, LeftLeg );
|
||||||
DrawRotate( -0.1875f, 0.5f, 0, 0, eighthPi, eighthPi, LeftLeg );
|
DrawRotate( -0.1875f, 0.5f, 0, 0, eighthPi, eighthPi, LeftLeg );
|
||||||
DrawRotate( -0.1875f, 0.5f, 0, 0, -eighthPi, eighthPi, LeftLeg );
|
DrawRotate( -0.1875f, 0.5f, 0, 0, -eighthPi, eighthPi, LeftLeg );
|
||||||
DrawRotate( -0.1875f, 0.5f, 0, 0, -quarterPi, eighthPi, LeftLeg );
|
DrawRotate( -0.1875f, 0.5f, 0, 0, -quarterPi, eighthPi, LeftLeg );
|
||||||
DrawRotate( 0.1875f, 0.5f, 0, 0, -quarterPi, -eighthPi, RightLeg );
|
DrawRotate( 0.1875f, 0.5f, 0, 0, -quarterPi, -eighthPi, RightLeg );
|
||||||
DrawRotate( 0.1875f, 0.5f, 0, 0, -eighthPi, -eighthPi, RightLeg );
|
DrawRotate( 0.1875f, 0.5f, 0, 0, -eighthPi, -eighthPi, RightLeg );
|
||||||
DrawRotate( 0.1875f, 0.5f, 0, 0, eighthPi, -eighthPi, RightLeg );
|
DrawRotate( 0.1875f, 0.5f, 0, 0, eighthPi, -eighthPi, RightLeg );
|
||||||
DrawRotate( 0.1875f, 0.5f, 0, 0, quarterPi, -eighthPi, RightLeg );
|
DrawRotate( 0.1875f, 0.5f, 0, 0, quarterPi, -eighthPi, RightLeg );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() {
|
|
||||||
graphics.DeleteTexture( ref DefaultTexId );
|
|
||||||
}
|
|
||||||
|
|
||||||
ModelPart Head, Link, End, LeftLeg, RightLeg;
|
ModelPart Head, Link, End, LeftLeg, RightLeg;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,8 @@ namespace ClassicalSharp.Model {
|
|||||||
LeftArm = MakeLeftArm( 0.5f, 0.25f );
|
LeftArm = MakeLeftArm( 0.5f, 0.25f );
|
||||||
RightArm = MakeRightArm( 0.25f, 0.5f );
|
RightArm = MakeRightArm( 0.25f, 0.5f );
|
||||||
|
|
||||||
DefaultTexId = graphics.CreateTexture( "zombie.png" );
|
if( cache.ZombieTexId <= 0 )
|
||||||
|
cache.ZombieTexId = graphics.CreateTexture( "zombie.png" );
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelPart MakeLeftArm( float x1, float x2 ) {
|
ModelPart MakeLeftArm( float x1, float x2 ) {
|
||||||
@ -56,7 +57,7 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
protected override void DrawPlayerModel( Player p ) {
|
protected override void DrawPlayerModel( Player p ) {
|
||||||
graphics.Texturing = true;
|
graphics.Texturing = true;
|
||||||
int texId = p.MobTextureId <= 0 ? DefaultTexId : p.MobTextureId;
|
int texId = p.MobTextureId <= 0 ? cache.ZombieTexId : p.MobTextureId;
|
||||||
graphics.BindTexture( texId );
|
graphics.BindTexture( texId );
|
||||||
|
|
||||||
DrawRotate( 0, 1.5f, 0, -p.PitchRadians, 0, 0, Head );
|
DrawRotate( 0, 1.5f, 0, -p.PitchRadians, 0, 0, Head );
|
||||||
@ -68,10 +69,6 @@ namespace ClassicalSharp.Model {
|
|||||||
graphics.AlphaTest = true;
|
graphics.AlphaTest = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() {
|
|
||||||
graphics.DeleteTexture( ref DefaultTexId );
|
|
||||||
}
|
|
||||||
|
|
||||||
ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm;
|
ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,6 +3,8 @@ using System.Drawing;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using ClassicalSharp.Model;
|
||||||
|
using ClassicalSharp.GraphicsAPI;
|
||||||
|
|
||||||
namespace ClassicalSharp.TexturePack {
|
namespace ClassicalSharp.TexturePack {
|
||||||
|
|
||||||
@ -46,7 +48,7 @@ namespace ClassicalSharp.TexturePack {
|
|||||||
Utils.LogWarning( "May not be able to properly extract a .zip enty with a version later than 2.0" );
|
Utils.LogWarning( "May not be able to properly extract a .zip enty with a version later than 2.0" );
|
||||||
|
|
||||||
byte[] data = DecompressEntry( reader, compressionMethod, compressedSize, uncompressedSize );
|
byte[] data = DecompressEntry( reader, compressionMethod, compressedSize, uncompressedSize );
|
||||||
if( data != null )
|
if( data != null )
|
||||||
HandleZipEntry( fileName, data );
|
HandleZipEntry( fileName, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,14 +71,44 @@ namespace ClassicalSharp.TexturePack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*ChickenTexId, CreeperTexId, PigTexId, SheepTexId,
|
||||||
|
SkeletonTexId, SpiderTexId, ZombieTexId, SheepFurTexId, HumanoidTexId;*/
|
||||||
void HandleZipEntry( string filename, byte[] data ) {
|
void HandleZipEntry( string filename, byte[] data ) {
|
||||||
Console.WriteLine( filename );
|
Console.WriteLine( filename );
|
||||||
MemoryStream stream = new MemoryStream( data );
|
MemoryStream stream = new MemoryStream( data );
|
||||||
|
ModelCache cache = game.ModelCache;
|
||||||
|
IGraphicsApi api = game.Graphics;
|
||||||
|
|
||||||
switch( filename ) {
|
switch( filename ) {
|
||||||
case "terrain.png":
|
case "terrain.png":
|
||||||
game.ChangeTerrainAtlas( new Bitmap( stream ) );
|
game.ChangeTerrainAtlas( new Bitmap( stream ) ); break;
|
||||||
break;
|
case "chicken.png":
|
||||||
|
UpdateTexture( ref cache.ChickenTexId, stream, false ); break;
|
||||||
|
case "creeper.png":
|
||||||
|
UpdateTexture( ref cache.CreeperTexId, stream, false ); break;
|
||||||
|
case "pig.png":
|
||||||
|
UpdateTexture( ref cache.PigTexId, stream, false ); break;
|
||||||
|
case "sheep.png":
|
||||||
|
UpdateTexture( ref cache.SheepTexId, stream, false ); break;
|
||||||
|
case "skeleton.png":
|
||||||
|
UpdateTexture( ref cache.SkeletonTexId, stream, false ); break;
|
||||||
|
case "spider.png":
|
||||||
|
UpdateTexture( ref cache.SpiderTexId, stream, false ); break;
|
||||||
|
case "zombie.png":
|
||||||
|
UpdateTexture( ref cache.ZombieTexId, stream, false ); break;
|
||||||
|
case "sheep_fur.png":
|
||||||
|
UpdateTexture( ref cache.SheepFurTexId, stream, false ); break;
|
||||||
|
case "char.png":
|
||||||
|
UpdateTexture( ref cache.HumanoidTexId, stream, true ); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateTexture( ref int texId, Stream stream, bool setSkinType ) {
|
||||||
|
game.Graphics.DeleteTexture( ref texId );
|
||||||
|
using( Bitmap bmp = new Bitmap( stream ) ) {
|
||||||
|
if( setSkinType )
|
||||||
|
game.DefaultPlayerSkinType = Utils.GetSkinType( bmp );
|
||||||
|
texId = game.Graphics.CreateTexture( bmp );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user