mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-08 14:56:12 -04:00
Fix and simplify some things, added skeleton model.
This commit is contained in:
parent
13d4b8470a
commit
037a8144cc
@ -118,6 +118,7 @@
|
||||
<Compile Include="Model\ModelPart.cs" />
|
||||
<Compile Include="Model\PigModel.cs" />
|
||||
<Compile Include="Model\PlayerModel.cs" />
|
||||
<Compile Include="Model\SkeletonModel.cs" />
|
||||
<Compile Include="Model\ZombieModel.cs" />
|
||||
<Compile Include="Network\Enums.cs" />
|
||||
<Compile Include="Network\FastNetReader.cs" />
|
||||
|
@ -14,10 +14,10 @@ namespace ClassicalSharp.Model {
|
||||
Set = new ModelSet();
|
||||
Set.Head = MakeHead();
|
||||
Set.Torso = MakeTorso();
|
||||
Set.LeftLegFront = MakeLeg( 0, 16, -0.25f, 0, -0.375f, -0.125f );
|
||||
Set.RightLegFront = MakeLeg( 0, 16, 0, 0.25f, -0.375f, -0.125f );
|
||||
Set.LeftLegBack = MakeLeg( 0, 16, -0.25f, 0, 0.125f, 0.375f );
|
||||
Set.RightLegBack = MakeLeg( 0, 16, 0, 0.25f, 0.125f, 0.375f );
|
||||
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" );
|
||||
@ -31,8 +31,8 @@ namespace ClassicalSharp.Model {
|
||||
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( int x, int y, float x1, float x2, float z1, float z2 ) {
|
||||
return MakePart( x, y, 4, 6, 4, 4, 4, 6, x1, x2, 0f, 0.375f, z1, z2, 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 {
|
||||
|
@ -54,7 +54,7 @@ namespace ClassicalSharp.Model {
|
||||
}
|
||||
|
||||
public override float NameYOffset {
|
||||
get { return 1.7f; }
|
||||
get { return 1.075f; }
|
||||
}
|
||||
|
||||
Vector3 pos;
|
||||
|
109
Model/SkeletonModel.cs
Normal file
109
Model/SkeletonModel.cs
Normal file
@ -0,0 +1,109 @@
|
||||
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; }
|
||||
}
|
||||
|
||||
Vector3 pos;
|
||||
float yaw, pitch;
|
||||
float rightLegXRot, rightArmZRot;
|
||||
float leftLegXRot, leftArmZRot;
|
||||
|
||||
public override void RenderModel( Player player, PlayerRenderer renderer ) {
|
||||
pos = player.Position;
|
||||
yaw = player.YawDegrees;
|
||||
pitch = player.PitchDegrees;
|
||||
|
||||
leftLegXRot = player.leftLegXRot * 180 / (float)Math.PI;
|
||||
leftArmZRot = player.leftArmZRot * 180 / (float)Math.PI;
|
||||
rightLegXRot = player.rightLegXRot * 180 / (float)Math.PI;
|
||||
rightArmZRot = player.rightArmZRot * 180 / (float)Math.PI;
|
||||
|
||||
graphics.PushMatrix();
|
||||
graphics.Translate( pos.X, pos.Y, pos.Z );
|
||||
graphics.RotateY( -yaw );
|
||||
DrawPlayerModel( player, renderer );
|
||||
graphics.PopMatrix();
|
||||
}
|
||||
|
||||
private void DrawPlayerModel( Player player, PlayerRenderer renderer ) {
|
||||
graphics.Texturing = true;
|
||||
graphics.AlphaTest = true;
|
||||
int texId = DefaultSkinTextureId;
|
||||
graphics.Bind2DTexture( texId );
|
||||
|
||||
DrawRotateX( 0, 1.5f, 0, -pitch, Set.Head );
|
||||
Set.Torso.Render();
|
||||
DrawRotateX( 0, 0.75f, 0, leftLegXRot, Set.LeftLeg );
|
||||
DrawRotateX( 0, 0.75f, 0, rightLegXRot, Set.RightLeg );
|
||||
DrawRotateXZ( 0, 1.375f, 0, 90f, leftArmZRot, Set.LeftArm );
|
||||
DrawRotateXZ( 0, 1.375f, 0, 90f, 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -14,21 +14,21 @@ namespace ClassicalSharp.Model {
|
||||
Set = new ModelSet();
|
||||
Set.Head = MakeHead();
|
||||
Set.Torso = MakeTorso();
|
||||
Set.LeftLeg = MakeLeftLeg( 0, 16, 0.25f, 0f );
|
||||
Set.RightLeg = MakeRightLeg( 0, 16, 0, 0.25f );
|
||||
Set.LeftArm = MakeLeftArm( 40, 16, 0.5f, 0.25f, 4 );
|
||||
Set.RightArm = MakeRightArm( 40, 16, 0.25f, 0.5f, 4 );
|
||||
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( int x, int y, float x1, float x2, int width ) {
|
||||
return MakePart( x, y, 4, 12, width, 4, width, 12, -x2, -x1, 0.75f, 1.5f, -0.125f, 0.125f, false );
|
||||
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( int x, int y, float x1, float x2, int width ) {
|
||||
return MakePart( x, y, 4, 12, width, 4, width, 12, x1, x2, 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() {
|
||||
@ -39,22 +39,22 @@ namespace ClassicalSharp.Model {
|
||||
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( int x, int y, float x1, float x2 ) {
|
||||
return MakePart( x, y, 4, 12, 4, 4, 4, 12, -x2, -x1, 0f, 0.75f, -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( int x, int y, float x1, float x2 ) {
|
||||
return MakePart( x, y, 4, 12, 4, 4, 4, 12, x1, x2, 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.1375f; }
|
||||
get { return 2.075f; }
|
||||
}
|
||||
|
||||
Vector3 pos;
|
||||
float yaw, pitch;
|
||||
float rightLegXRot, rightArmXRot, rightArmZRot;
|
||||
float leftLegXRot, leftArmXRot, leftArmZRot;
|
||||
float rightLegXRot, rightArmZRot;
|
||||
float leftLegXRot, leftArmZRot;
|
||||
|
||||
public override void RenderModel( Player player, PlayerRenderer renderer ) {
|
||||
pos = player.Position;
|
||||
@ -62,10 +62,8 @@ namespace ClassicalSharp.Model {
|
||||
pitch = player.PitchDegrees;
|
||||
|
||||
leftLegXRot = player.leftLegXRot * 180 / (float)Math.PI;
|
||||
leftArmXRot = player.leftArmXRot * 180 / (float)Math.PI;
|
||||
leftArmZRot = player.leftArmZRot * 180 / (float)Math.PI;
|
||||
rightLegXRot = player.rightLegXRot * 180 / (float)Math.PI;
|
||||
rightArmXRot = player.rightArmXRot * 180 / (float)Math.PI;
|
||||
rightArmZRot = player.rightArmZRot * 180 / (float)Math.PI;
|
||||
|
||||
graphics.PushMatrix();
|
||||
@ -84,8 +82,8 @@ namespace ClassicalSharp.Model {
|
||||
Set.Torso.Render();
|
||||
DrawRotateX( 0, 0.75f, 0, leftLegXRot, Set.LeftLeg );
|
||||
DrawRotateX( 0, 0.75f, 0, rightLegXRot, Set.RightLeg );
|
||||
DrawRotateXZ( 0, 1.5f, 0, leftArmXRot, leftArmZRot, Set.LeftArm );
|
||||
DrawRotateXZ( 0, 1.5f, 0, rightArmXRot, rightArmZRot, Set.RightArm );
|
||||
DrawRotateXZ( 0, 1.375f, 0, 90f, leftArmZRot, Set.LeftArm );
|
||||
DrawRotateXZ( 0, 1.375f, 0, 90f, rightArmZRot, Set.RightArm );
|
||||
graphics.AlphaTest = true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user