2015-01-03 18:28:15 +11:00
|
|
|
|
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 ) {
|
2015-06-01 06:45:22 +10:00
|
|
|
|
vertices = new VertexPos3fTex2fCol4b[partVertices * 6];
|
2015-01-03 18:28:15 +11:00
|
|
|
|
Set = new ModelSet();
|
|
|
|
|
Set.Head = MakeHead();
|
|
|
|
|
Set.Torso = MakeTorso();
|
2015-01-04 09:14:18 +11:00
|
|
|
|
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 );
|
2015-06-01 06:45:22 +10:00
|
|
|
|
|
|
|
|
|
vb = graphics.InitVb( vertices, VertexFormat.Pos3fTex2fCol4b );
|
|
|
|
|
Set.SetVb( vb );
|
|
|
|
|
vertices = null;
|
2015-05-19 06:30:52 +10:00
|
|
|
|
DefaultTexId = graphics.LoadTexture( "zombie.png" );
|
2015-01-03 18:28:15 +11:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-04 09:14:18 +11:00
|
|
|
|
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 );
|
2015-01-03 18:28:15 +11:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-04 09:14:18 +11:00
|
|
|
|
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 );
|
2015-01-03 18:28:15 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ModelPart MakeHead() {
|
2015-01-03 19:20:52 +11:00
|
|
|
|
return MakePart( 0, 0, 8, 8, 8, 8, 8, 8, -0.25f, 0.25f, 1.5f, 2f, -0.25f, 0.25f, false );
|
2015-01-03 18:28:15 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ModelPart MakeTorso() {
|
2015-01-03 19:20:52 +11:00
|
|
|
|
return MakePart( 16, 16, 4, 12, 8, 4, 8, 12, -0.25f, 0.25f, 0.75f, 1.5f, -0.125f, 0.125f, false );
|
2015-01-03 18:28:15 +11:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-04 09:14:18 +11:00
|
|
|
|
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 );
|
2015-01-03 18:28:15 +11:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-04 09:14:18 +11:00
|
|
|
|
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 );
|
2015-01-03 18:28:15 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override float NameYOffset {
|
2015-01-04 09:14:18 +11:00
|
|
|
|
get { return 2.075f; }
|
2015-01-03 18:28:15 +11:00
|
|
|
|
}
|
2015-07-03 09:20:46 +10:00
|
|
|
|
|
|
|
|
|
public override Vector3 CollisionSize {
|
|
|
|
|
get { return new Vector3( 8 / 16f, 30 / 16f, 8 / 16f ); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override BoundingBox PickingBounds {
|
|
|
|
|
get { return new BoundingBox( -4 / 16f, 0, -4 / 16f, 4 / 16f, 32 / 16f, 4 / 16f ); }
|
|
|
|
|
}
|
2015-01-03 18:28:15 +11:00
|
|
|
|
|
2015-07-05 19:59:26 +10:00
|
|
|
|
protected override void DrawPlayerModel( Player p, PlayerRenderer renderer ) {
|
2015-01-03 18:28:15 +11:00
|
|
|
|
graphics.Texturing = true;
|
2015-05-19 06:30:52 +10:00
|
|
|
|
int texId = renderer.MobTextureId <= 0 ? DefaultTexId : renderer.MobTextureId;
|
2015-01-03 18:28:15 +11:00
|
|
|
|
graphics.Bind2DTexture( texId );
|
|
|
|
|
|
2015-07-05 19:59:26 +10:00
|
|
|
|
DrawRotate( 0, 1.5f, 0, -p.PitchRadians, 0, 0, Set.Head );
|
2015-01-03 18:28:15 +11:00
|
|
|
|
Set.Torso.Render();
|
2015-07-05 19:59:26 +10:00
|
|
|
|
DrawRotate( 0, 0.75f, 0, p.leftLegXRot, 0, 0, Set.LeftLeg );
|
|
|
|
|
DrawRotate( 0, 0.75f, 0, p.rightLegXRot, 0, 0, Set.RightLeg );
|
|
|
|
|
DrawRotate( 0, 1.375f, 0, (float)Math.PI / 2, 0, p.leftArmZRot, Set.LeftArm );
|
|
|
|
|
DrawRotate( 0, 1.375f, 0, (float)Math.PI / 2, 0, p.rightArmZRot, Set.RightArm );
|
2015-01-03 19:20:52 +11:00
|
|
|
|
graphics.AlphaTest = true;
|
2015-01-03 18:28:15 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Dispose() {
|
2015-06-01 06:45:22 +10:00
|
|
|
|
graphics.DeleteVb( vb );
|
2015-05-19 06:30:52 +10:00
|
|
|
|
graphics.DeleteTexture( ref DefaultTexId );
|
2015-01-03 18:28:15 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ModelSet {
|
|
|
|
|
|
|
|
|
|
public ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm;
|
|
|
|
|
|
2015-06-01 06:45:22 +10:00
|
|
|
|
public void SetVb( int vb ) {
|
|
|
|
|
Head.Vb = Torso.Vb = LeftLeg.Vb = RightLeg.Vb =
|
|
|
|
|
LeftArm.Vb = RightArm.Vb = vb;
|
2015-01-03 18:28:15 +11:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|