Initial implementation of head vs body yaw roation, also use default.png in more places instead of always hardcoding arial. (Thanks Vladcosmonaut)

This commit is contained in:
UnknownShadow200 2016-01-12 21:32:31 +11:00
parent 6621f81cda
commit bbe3820e95
25 changed files with 167 additions and 81 deletions

View File

@ -186,12 +186,12 @@ namespace ClassicalSharp {
string value = buffer.GetString(); string value = buffer.GetString();
DrawTextArgs args = new DrawTextArgs( value, font, true ); DrawTextArgs args = new DrawTextArgs( value, font, true );
Size size = game.Drawer2D.MeasureSize( ref args ); Size size = game.Drawer2D.MeasureChatSize( ref args );
int x = startX + (blockSize * blocksPerRow) / 2 - size.Width / 2; int x = startX + (blockSize * blocksPerRow) / 2 - size.Width / 2;
int y = startY - size.Height - 5; int y = startY - size.Height - 5;
args.SkipPartsCheck = true; args.SkipPartsCheck = true;
blockInfoTexture = game.Drawer2D.MakeTextTexture( ref args, x, y ); blockInfoTexture = game.Drawer2D.MakeChatTextTexture( ref args, x, y );
} }
void RecreateBlockTable() { void RecreateBlockTable() {

View File

@ -116,7 +116,7 @@ namespace ClassicalSharp {
void AddPlayerInfo( CpeListInfo player, int index ) { void AddPlayerInfo( CpeListInfo player, int index ) {
DrawTextArgs args = new DrawTextArgs( player.ListName, font, true ); DrawTextArgs args = new DrawTextArgs( player.ListName, font, true );
Texture tex = game.Drawer2D.MakeTextTexture( ref args, 0, 0 ); Texture tex = game.Drawer2D.MakeChatTextTexture( ref args, 0, 0 );
if( index < 0 ) { if( index < 0 ) {
info[namesCount] = new PlayerInfo( player ); info[namesCount] = new PlayerInfo( player );
textures[namesCount] = tex; textures[namesCount] = tex;
@ -159,7 +159,7 @@ namespace ClassicalSharp {
void AddGroup( string group, ref int index ) { void AddGroup( string group, ref int index ) {
DrawTextArgs args = new DrawTextArgs( group, titleFont, true ); DrawTextArgs args = new DrawTextArgs( group, titleFont, true );
Texture tex = game.Drawer2D.MakeTextTexture( ref args, 0, 0 ); Texture tex = game.Drawer2D.MakeChatTextTexture( ref args, 0, 0 );
PlayerInfo pInfo = new PlayerInfo( group ); PlayerInfo pInfo = new PlayerInfo( group );
PushDown( info, index, pInfo ); PushDown( info, index, pInfo );

View File

@ -61,7 +61,7 @@ namespace ClassicalSharp {
void AddPlayerInfo( Player player ) { void AddPlayerInfo( Player player ) {
DrawTextArgs args = new DrawTextArgs( player.DisplayName, font, true ); DrawTextArgs args = new DrawTextArgs( player.DisplayName, font, true );
Texture tex = game.Drawer2D.MakeTextTexture( ref args, 0, 0 ); Texture tex = game.Drawer2D.MakeChatTextTexture( ref args, 0, 0 );
info[namesCount] = new PlayerInfo( player ); info[namesCount] = new PlayerInfo( player );
textures[namesCount] = tex; textures[namesCount] = tex;
namesCount++; namesCount++;

View File

@ -19,12 +19,18 @@ namespace ClassicalSharp {
public Vector3 Position; public Vector3 Position;
public Vector3 Velocity; public Vector3 Velocity;
public float YawDegrees, PitchDegrees; public float HeadYawDegrees, YawDegrees, PitchDegrees;
protected Game game; protected Game game;
protected BlockInfo info; protected BlockInfo info;
/// <summary> Rotation of the entity horizontally (i.e. looking north or east) </summary> /// <summary> Rotation of the entity's head horizontally (i.e. looking north or east) </summary>
public float HeadYawRadians {
get { return HeadYawDegrees * Utils.Deg2Rad; }
set { HeadYawDegrees = value * Utils.Rad2Deg; }
}
/// <summary> Rotation of the entity's body horizontally (i.e. looking north or east) </summary>
public float YawRadians { public float YawRadians {
get { return YawDegrees * Utils.Deg2Rad; } get { return YawDegrees * Utils.Deg2Rad; }
set { YawDegrees = value * Utils.Rad2Deg; } set { YawDegrees = value * Utils.Rad2Deg; }

View File

@ -58,7 +58,7 @@ namespace ClassicalSharp {
api.AlphaTest = true; api.AlphaTest = true;
LocalPlayer localP = game.LocalPlayer; LocalPlayer localP = game.LocalPlayer;
Vector3 eyePos = localP.EyePosition; Vector3 eyePos = localP.EyePosition;
Vector3 dir = Utils.GetDirVector( localP.YawRadians, localP.PitchRadians ); Vector3 dir = Utils.GetDirVector( localP.HeadYawRadians, localP.PitchRadians );
closestId = 255; closestId = 255;
if( NamesMode != NameMode.AllNames ) if( NamesMode != NameMode.AllNames )
@ -112,7 +112,7 @@ namespace ClassicalSharp {
public byte GetClosetPlayer( LocalPlayer localP ) { public byte GetClosetPlayer( LocalPlayer localP ) {
Vector3 eyePos = localP.EyePosition; Vector3 eyePos = localP.EyePosition;
Vector3 dir = Utils.GetDirVector( localP.YawRadians, localP.PitchRadians ); Vector3 dir = Utils.GetDirVector( localP.HeadYawRadians, localP.PitchRadians );
float closestDist = float.PositiveInfinity; float closestDist = float.PositiveInfinity;
byte targetId = 255; byte targetId = 255;

View File

@ -140,7 +140,7 @@ namespace ClassicalSharp {
if( dist < 1 ) dist = 1; if( dist < 1 ) dist = 1;
float multiply = factor / dist; float multiply = factor / dist;
Velocity += Utils.RotateY( x * multiply, 0, z * multiply, YawRadians ); Velocity += Utils.RotateY( x * multiply, 0, z * multiply, HeadYawRadians );
} }
void MoveFlying( float xMoving, float zMoving, float factor, Vector3 drag, float gravity, float yMul ) { void MoveFlying( float xMoving, float zMoving, float factor, Vector3 drag, float gravity, float yMul ) {

View File

@ -85,24 +85,6 @@ namespace ClassicalSharp {
InitRenderingData(); InitRenderingData();
} }
public override void SetLocation( LocationUpdate update, bool interpolate ) {
if( update.IncludesPosition ) {
nextPos = update.RelativePosition ? nextPos + update.Pos : update.Pos;
nextPos.Y += Entity.Adjustment;
if( !interpolate ) {
lastPos = Position = nextPos;
}
}
if( update.IncludesOrientation ) {
nextYaw = update.Yaw;
nextPitch = update.Pitch;
if( !interpolate ) {
lastYaw = YawDegrees = nextYaw;
lastPitch = PitchDegrees = nextPitch;
}
}
}
Vector3 lastSoundPos = new Vector3( float.PositiveInfinity ); Vector3 lastSoundPos = new Vector3( float.PositiveInfinity );
public override void Tick( double delta ) { public override void Tick( double delta ) {
if( game.Map.IsNotLoaded ) return; if( game.Map.IsNotLoaded ) return;
@ -132,6 +114,7 @@ namespace ClassicalSharp {
game.AudioPlayer.PlayStepSound( type ); game.AudioPlayer.PlayStepSound( type );
lastSoundPos = soundPos; lastSoundPos = soundPos;
} }
UpdateCurrentBodyYaw();
} }
bool DoPlaySound( Vector3 soundPos ) { bool DoPlaySound( Vector3 soundPos ) {
@ -282,14 +265,55 @@ namespace ClassicalSharp {
internal Vector3 lastPos, nextPos; internal Vector3 lastPos, nextPos;
internal float lastYaw, nextYaw, lastPitch, nextPitch; internal float lastYaw, nextYaw, lastPitch, nextPitch;
float newYaw, oldYaw;
int yawStateCount;
float[] yawStates = new float[15];
public override void SetLocation( LocationUpdate update, bool interpolate ) {
if( update.IncludesPosition ) {
nextPos = update.RelativePosition ? nextPos + update.Pos : update.Pos;
nextPos.Y += Entity.Adjustment;
if( !interpolate ) {
lastPos = Position = nextPos;
}
}
if( update.IncludesOrientation ) {
nextYaw = update.Yaw;
nextPitch = update.Pitch;
if( !interpolate ) {
lastYaw = YawDegrees = nextYaw;
lastPitch = PitchDegrees = nextPitch;
HeadYawDegrees = YawDegrees;
yawStateCount = 0;
} else {
for( int i = 0; i < 3; i++ )
AddYaw( Utils.LerpAngle( lastYaw, nextYaw, (i + 1) / 3f ) );
}
}
}
/// <summary> Linearly interpolates position and rotation between the previous and next state. </summary> /// <summary> Linearly interpolates position and rotation between the previous and next state. </summary>
public void SetInterpPosition( float t ) { public void SetInterpPosition( float t ) {
Position = Vector3.Lerp( lastPos, nextPos, t ); Position = Vector3.Lerp( lastPos, nextPos, t );
YawDegrees = Utils.LerpAngle( lastYaw, nextYaw, t ); HeadYawDegrees = Utils.LerpAngle( lastYaw, nextYaw, t );
YawDegrees = Utils.LerpAngle( oldYaw, newYaw, t );
PitchDegrees = Utils.LerpAngle( lastPitch, nextPitch, t ); PitchDegrees = Utils.LerpAngle( lastPitch, nextPitch, t );
} }
void AddYaw( float state ) {
if( yawStateCount == yawStates.Length )
RemoveOldest( yawStates, ref yawStateCount );
yawStates[yawStateCount++] = state;
}
void UpdateCurrentBodyYaw() {
oldYaw = newYaw;
if( yawStateCount > 0 ) {
newYaw = yawStates[0];
RemoveOldest( yawStates, ref yawStateCount );
}
}
internal bool HandleKeyDown( Key key ) { internal bool HandleKeyDown( Key key ) {
KeyMap keys = game.InputHandler.Keys; KeyMap keys = game.InputHandler.Keys;
if( key == keys[KeyBinding.Respawn] && CanRespawn && HacksEnabled ) { if( key == keys[KeyBinding.Respawn] && CanRespawn && HacksEnabled ) {
@ -311,7 +335,7 @@ namespace ClassicalSharp {
SetLocation( update, false ); SetLocation( update, false );
} else if( key == keys[KeyBinding.SetSpawn] && CanRespawn && HacksEnabled ) { } else if( key == keys[KeyBinding.SetSpawn] && CanRespawn && HacksEnabled ) {
SpawnPoint = Position; SpawnPoint = Position;
SpawnYaw = YawDegrees; SpawnYaw = HeadYawDegrees;
SpawnPitch = PitchDegrees; SpawnPitch = PitchDegrees;
} else if( key == keys[KeyBinding.Fly] && CanFly && HacksEnabled ) { } else if( key == keys[KeyBinding.Fly] && CanFly && HacksEnabled ) {
flying = !flying; flying = !flying;

View File

@ -25,13 +25,14 @@ namespace ClassicalSharp {
serverPos = update.RelativePosition ? serverPos + update.Pos : update.Pos; serverPos = update.RelativePosition ? serverPos + update.Pos : update.Pos;
} }
if( update.IncludesOrientation ) { if( update.IncludesOrientation ) {
serverYaw = update.Yaw; serverYaw = update.Yaw; serverPitch = update.Pitch;
serverPitch = update.Pitch;
} }
if( !interpolate ) { if( !interpolate ) {
stateCount = 0; stateCount = 0;
newState = oldState = new State( tickCount, serverPos, serverYaw, serverPitch ); newState = oldState = new State( tickCount, serverPos, serverYaw, serverPitch );
yawStateCount = 0;
newYaw = oldYaw = serverYaw;
} else { } else {
// Smoother interpolation by also adding midpoint. // Smoother interpolation by also adding midpoint.
Vector3 midPos = Vector3.Lerp( lastPos, serverPos, 0.5f ); Vector3 midPos = Vector3.Lerp( lastPos, serverPos, 0.5f );
@ -39,25 +40,30 @@ namespace ClassicalSharp {
float midPitch = Utils.LerpAngle( lastPitch, serverPitch, 0.5f ); float midPitch = Utils.LerpAngle( lastPitch, serverPitch, 0.5f );
AddState( new State( tickCount, midPos, midYaw, midPitch ) ); AddState( new State( tickCount, midPos, midYaw, midPitch ) );
AddState( new State( tickCount, serverPos, serverYaw, serverPitch ) ); AddState( new State( tickCount, serverPos, serverYaw, serverPitch ) );
for( int i = 0; i < 3; i++ )
AddYaw( Utils.LerpAngle( lastYaw, serverYaw, (i + 1) / 3f ) );
} }
} }
struct State { struct State {
public int tick; public int tick;
public Vector3 pos; public Vector3 pos;
public float yaw, pitch; public float headYaw, pitch;
public State( int tick, Vector3 pos, float yaw, float pitch ) { public State( int tick, Vector3 pos, float headYaw, float pitch ) {
this.tick = tick; this.tick = tick;
this.pos = pos; this.pos = pos;
this.yaw = yaw; this.headYaw = headYaw;
this.pitch = pitch; this.pitch = pitch;
} }
} }
State[] states = new State[10]; State[] states = new State[10];
float[] yawStates = new float[15];
State newState, oldState; State newState, oldState;
int stateCount; float newYaw, oldYaw;
int stateCount, yawStateCount;
public override void Tick( double delta ) { public override void Tick( double delta ) {
CheckSkin(); CheckSkin();
tickCount++; tickCount++;
@ -67,29 +73,34 @@ namespace ClassicalSharp {
void AddState( State state ) { void AddState( State state ) {
if( stateCount == states.Length ) if( stateCount == states.Length )
RemoveOldestState(); RemoveOldest( states, ref stateCount );
states[stateCount++] = state; states[stateCount++] = state;
} }
void RemoveOldestState() { void AddYaw( float state ) {
for( int i = 0; i < states.Length - 1; i++ ) { if( yawStateCount == yawStates.Length )
states[i] = states[i + 1]; RemoveOldest( yawStates, ref yawStateCount );
} yawStates[yawStateCount++] = state;
stateCount--;
} }
void UpdateCurrentState() { void UpdateCurrentState() {
oldState = newState; oldState = newState;
if( stateCount == 0 ) return; oldYaw = newYaw;
if( stateCount > 0 ) {
//if( states[0].tick > tickCount - 2 ) return; // 100 ms delay //if( states[0].tick > tickCount - 2 ) return; // 100 ms delay
newState = states[0]; newState = states[0];
RemoveOldestState(); RemoveOldest( states, ref stateCount );
}
if( yawStateCount > 0 ) {
newYaw = yawStates[0];
RemoveOldest( yawStates, ref yawStateCount );
}
} }
public override void RenderModel( double deltaTime, float t ) { public override void RenderModel( double deltaTime, float t ) {
Position = Vector3.Lerp( oldState.pos, newState.pos, t ); Position = Vector3.Lerp( oldState.pos, newState.pos, t );
YawDegrees = Utils.LerpAngle( oldState.yaw, newState.yaw, t ); HeadYawDegrees = Utils.LerpAngle( oldState.headYaw, newState.headYaw, t );
YawDegrees = Utils.LerpAngle( oldYaw, newYaw, t );
PitchDegrees = Utils.LerpAngle( oldState.pitch, newState.pitch, t ); PitchDegrees = Utils.LerpAngle( oldState.pitch, newState.pitch, t );
GetCurrentAnimState( t ); GetCurrentAnimState( t );

View File

@ -115,5 +115,11 @@ namespace ClassicalSharp {
} }
} }
} }
protected void RemoveOldest<T>(T[] array, ref int count) {
for( int i = 0; i < array.Length - 1; i++ )
array[i] = array[i + 1];
count--;
}
} }
} }

View File

@ -70,6 +70,8 @@ namespace ClassicalSharp.Model {
block = Byte.Parse( p.ModelName ); block = Byte.Parse( p.ModelName );
} }
cosA = (float)Math.Cos( p.YawRadians );
sinA = (float)Math.Sin( p.YawRadians );
CalcState( block ); CalcState( block );
if( game.BlockInfo.IsAir[block] ) if( game.BlockInfo.IsAir[block] )
return; return;

View File

@ -56,9 +56,14 @@ namespace ClassicalSharp.Model {
int texId = p.MobTextureId <= 0 ? cache.ChickenTexId : p.MobTextureId; int texId = p.MobTextureId <= 0 ? cache.ChickenTexId : p.MobTextureId;
graphics.BindTexture( texId ); graphics.BindTexture( texId );
cosA = (float)Math.Cos( p.HeadYawRadians );
sinA = (float)Math.Sin( p.HeadYawRadians );
DrawRotate( 0, 9/16f, -3/16f, -p.PitchRadians, 0, 0, Head ); DrawRotate( 0, 9/16f, -3/16f, -p.PitchRadians, 0, 0, Head );
DrawRotate( 0, 9/16f, -3/16f, -p.PitchRadians, 0, 0, Head2 ); DrawRotate( 0, 9/16f, -3/16f, -p.PitchRadians, 0, 0, Head2 );
DrawRotate( 0, 9/16f, -3/16f, -p.PitchRadians, 0, 0, Head3 ); DrawRotate( 0, 9/16f, -3/16f, -p.PitchRadians, 0, 0, Head3 );
cosA = (float)Math.Cos( p.YawRadians );
sinA = (float)Math.Sin( p.YawRadians );
DrawPart( Torso ); DrawPart( Torso );
DrawRotate( 0, 5/16f, 1/16f, p.legXRot, 0, 0, LeftLeg ); DrawRotate( 0, 5/16f, 1/16f, p.legXRot, 0, 0, LeftLeg );
DrawRotate( 0, 5/16f, 1/16f, -p.legXRot, 0, 0, RightLeg ); DrawRotate( 0, 5/16f, 1/16f, -p.legXRot, 0, 0, RightLeg );

View File

@ -46,8 +46,12 @@ namespace ClassicalSharp.Model {
protected override void DrawPlayerModel( Player p ) { protected override void DrawPlayerModel( Player p ) {
int texId = p.MobTextureId <= 0 ? cache.CreeperTexId : p.MobTextureId; int texId = p.MobTextureId <= 0 ? cache.CreeperTexId : p.MobTextureId;
graphics.BindTexture( texId ); graphics.BindTexture( texId );
cosA = (float)Math.Cos( p.HeadYawRadians );
sinA = (float)Math.Sin( p.HeadYawRadians );
DrawRotate( 0, 18/16f, 0, -p.PitchRadians, 0, 0, Head ); DrawRotate( 0, 18/16f, 0, -p.PitchRadians, 0, 0, Head );
cosA = (float)Math.Cos( p.YawRadians );
sinA = (float)Math.Sin( p.YawRadians );
DrawPart( Torso ); DrawPart( Torso );
DrawRotate( 0, 6/16f, -2/16f, p.legXRot, 0, 0, LeftLegFront ); DrawRotate( 0, 6/16f, -2/16f, p.legXRot, 0, 0, LeftLegFront );
DrawRotate( 0, 6/16f, -2/16f, -p.legXRot, 0, 0, RightLegFront ); DrawRotate( 0, 6/16f, -2/16f, -p.legXRot, 0, 0, RightLegFront );

View File

@ -51,8 +51,6 @@ namespace ClassicalSharp.Model {
pos = p.Position; pos = p.Position;
if( Bobbing ) if( Bobbing )
pos.Y += p.bobYOffset; pos.Y += p.bobYOffset;
cosA = (float)Math.Cos( p.YawRadians );
sinA = (float)Math.Sin( p.YawRadians );
Map map = game.Map; Map map = game.Map;
col = game.Map.IsLit( Vector3I.Floor( p.EyePosition ) ) ? map.Sunlight : map.Shadowlight; col = game.Map.IsLit( Vector3I.Floor( p.EyePosition ) ) ? map.Sunlight : map.Shadowlight;

View File

@ -45,8 +45,12 @@ namespace ClassicalSharp.Model {
protected override void DrawPlayerModel( Player p ) { protected override void DrawPlayerModel( Player p ) {
int texId = p.MobTextureId <= 0 ? cache.PigTexId : p.MobTextureId; int texId = p.MobTextureId <= 0 ? cache.PigTexId : p.MobTextureId;
graphics.BindTexture( texId ); graphics.BindTexture( texId );
cosA = (float)Math.Cos( p.HeadYawRadians );
sinA = (float)Math.Sin( p.HeadYawRadians );
DrawRotate( 0, 12/16f, -6/16f, -p.PitchRadians, 0, 0, Head ); DrawRotate( 0, 12/16f, -6/16f, -p.PitchRadians, 0, 0, Head );
cosA = (float)Math.Cos( p.YawRadians );
sinA = (float)Math.Sin( p.YawRadians );
DrawPart( Torso ); DrawPart( Torso );
DrawRotate( 0, 6/16f, -5/16f, p.legXRot, 0, 0, LeftLegFront ); DrawRotate( 0, 6/16f, -5/16f, p.legXRot, 0, 0, LeftLegFront );
DrawRotate( 0, 6/16f, -5/16f, -p.legXRot, 0, 0, RightLegFront ); DrawRotate( 0, 6/16f, -5/16f, -p.legXRot, 0, 0, RightLegFront );

View File

@ -68,8 +68,12 @@ namespace ClassicalSharp.Model {
SkinType skinType = p.SkinType; SkinType skinType = p.SkinType;
_64x64 = skinType != SkinType.Type64x32; _64x64 = skinType != SkinType.Type64x32;
ModelSet model = skinType == SkinType.Type64x64Slim ? SetSlim : Set; ModelSet model = skinType == SkinType.Type64x64Slim ? SetSlim : Set;
cosA = (float)Math.Cos( p.HeadYawRadians );
sinA = (float)Math.Sin( p.HeadYawRadians );
DrawRotate( 0, 24/16f, 0, -p.PitchRadians, 0, 0, model.Head ); DrawRotate( 0, 24/16f, 0, -p.PitchRadians, 0, 0, model.Head );
cosA = (float)Math.Cos( p.YawRadians );
sinA = (float)Math.Sin( p.YawRadians );
DrawPart( model.Torso ); DrawPart( model.Torso );
DrawRotate( 0, 12/16f, 0, p.legXRot, 0, 0, model.LeftLeg ); DrawRotate( 0, 12/16f, 0, p.legXRot, 0, 0, model.LeftLeg );
DrawRotate( 0, 12/16f, 0, -p.legXRot, 0, 0, model.RightLeg ); DrawRotate( 0, 12/16f, 0, -p.legXRot, 0, 0, model.RightLeg );
@ -81,6 +85,8 @@ namespace ClassicalSharp.Model {
graphics.AlphaTest = true; graphics.AlphaTest = true;
index = 0; index = 0;
cosA = (float)Math.Cos( p.HeadYawRadians );
sinA = (float)Math.Sin( p.HeadYawRadians );
DrawRotate( 0, 24f/16f, 0, -p.PitchRadians, 0, 0, model.Hat ); DrawRotate( 0, 24f/16f, 0, -p.PitchRadians, 0, 0, model.Hat );
graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 ); graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );
} }

View File

@ -67,8 +67,12 @@ namespace ClassicalSharp.Model {
protected override void DrawPlayerModel( Player p ) { protected override void DrawPlayerModel( Player p ) {
int texId = p.MobTextureId <= 0 ? cache.SheepTexId : p.MobTextureId; int texId = p.MobTextureId <= 0 ? cache.SheepTexId : p.MobTextureId;
graphics.BindTexture( texId ); graphics.BindTexture( texId );
cosA = (float)Math.Cos( p.HeadYawRadians );
sinA = (float)Math.Sin( p.HeadYawRadians );
DrawRotate( 0, 18/16f, -8/16f, -p.PitchRadians, 0, 0, Head ); DrawRotate( 0, 18/16f, -8/16f, -p.PitchRadians, 0, 0, Head );
cosA = (float)Math.Cos( p.YawRadians );
sinA = (float)Math.Sin( p.YawRadians );
DrawPart( Torso ); DrawPart( Torso );
DrawRotate( 0, 12/16f, -5/16f, p.legXRot, 0, 0, LeftLegFront ); DrawRotate( 0, 12/16f, -5/16f, p.legXRot, 0, 0, LeftLegFront );
DrawRotate( 0, 12/16f, -5/16f, -p.legXRot, 0, 0, RightLegFront ); DrawRotate( 0, 12/16f, -5/16f, -p.legXRot, 0, 0, RightLegFront );
@ -79,8 +83,13 @@ namespace ClassicalSharp.Model {
if( Fur ) { if( Fur ) {
graphics.BindTexture( cache.SheepFurTexId ); graphics.BindTexture( cache.SheepFurTexId );
DrawPart( FurTorso ); cosA = (float)Math.Cos( p.HeadYawRadians );
sinA = (float)Math.Sin( p.HeadYawRadians );
DrawRotate( 0, 18/16f, -8/16f, -p.PitchRadians, 0, 0, FurHead ); DrawRotate( 0, 18/16f, -8/16f, -p.PitchRadians, 0, 0, FurHead );
cosA = (float)Math.Cos( p.YawRadians );
sinA = (float)Math.Sin( p.YawRadians );
DrawPart( FurTorso );
DrawRotate( 0, 12/16f, -5/16f, p.legXRot, 0, 0, FurLeftLegFront ); DrawRotate( 0, 12/16f, -5/16f, p.legXRot, 0, 0, FurLeftLegFront );
DrawRotate( 0, 12/16f, -5/16f, -p.legXRot, 0, 0, FurRightLegFront ); DrawRotate( 0, 12/16f, -5/16f, -p.legXRot, 0, 0, FurRightLegFront );
DrawRotate( 0, 12/16f, 7/16f, -p.legXRot, 0, 0, FurLeftLegBack ); DrawRotate( 0, 12/16f, 7/16f, -p.legXRot, 0, 0, FurLeftLegBack );

View File

@ -45,8 +45,12 @@ namespace ClassicalSharp.Model {
protected override void DrawPlayerModel( Player p ) { protected override void DrawPlayerModel( Player p ) {
int texId = p.MobTextureId <= 0 ? cache.SkeletonTexId : p.MobTextureId; int texId = p.MobTextureId <= 0 ? cache.SkeletonTexId : p.MobTextureId;
graphics.BindTexture( texId ); graphics.BindTexture( texId );
cosA = (float)Math.Cos( p.HeadYawRadians );
sinA = (float)Math.Sin( p.HeadYawRadians );
DrawRotate( 0, 24/16f, 0, -p.PitchRadians, 0, 0, Head ); DrawRotate( 0, 24/16f, 0, -p.PitchRadians, 0, 0, Head );
cosA = (float)Math.Cos( p.YawRadians );
sinA = (float)Math.Sin( p.YawRadians );
DrawPart( Torso ); DrawPart( Torso );
DrawRotate( 0, 12/16f, 0, p.legXRot, 0, 0, LeftLeg ); DrawRotate( 0, 12/16f, 0, p.legXRot, 0, 0, LeftLeg );
DrawRotate( 0, 12/16f, 0, -p.legXRot, 0, 0, RightLeg ); DrawRotate( 0, 12/16f, 0, -p.legXRot, 0, 0, RightLeg );

View File

@ -45,11 +45,14 @@ namespace ClassicalSharp.Model {
protected override void DrawPlayerModel( Player p ) { protected override void DrawPlayerModel( Player p ) {
int texId = p.MobTextureId <= 0 ? cache.SpiderTexId : p.MobTextureId; int texId = p.MobTextureId <= 0 ? cache.SpiderTexId : p.MobTextureId;
graphics.BindTexture( texId ); graphics.BindTexture( texId );
cosA = (float)Math.Cos( p.HeadYawRadians );
sinA = (float)Math.Sin( p.HeadYawRadians );
DrawRotate( 0, 8/16f, -3/16f, -p.PitchRadians, 0, 0, Head ); DrawRotate( 0, 8/16f, -3/16f, -p.PitchRadians, 0, 0, Head );
cosA = (float)Math.Cos( p.YawRadians );
sinA = (float)Math.Sin( p.YawRadians );
DrawPart( Link ); DrawPart( Link );
DrawPart( End ); DrawPart( End );
float rotX = (float)(Math.Sin( p.walkTime ) * p.swing * Math.PI); float rotX = (float)(Math.Sin( p.walkTime ) * p.swing * Math.PI);
float rotZ = (float)(Math.Cos( p.walkTime * 2 ) * p.swing * Math.PI / 16f); float rotZ = (float)(Math.Cos( p.walkTime * 2 ) * p.swing * Math.PI / 16f);
float rotY = (float)(Math.Sin( p.walkTime * 2 ) * p.swing * Math.PI / 32f); float rotY = (float)(Math.Sin( p.walkTime * 2 ) * p.swing * Math.PI / 32f);

View File

@ -45,8 +45,12 @@ namespace ClassicalSharp.Model {
protected override void DrawPlayerModel( Player p ) { protected override void DrawPlayerModel( Player p ) {
int texId = p.MobTextureId <= 0 ? cache.ZombieTexId : p.MobTextureId; int texId = p.MobTextureId <= 0 ? cache.ZombieTexId : p.MobTextureId;
graphics.BindTexture( texId ); graphics.BindTexture( texId );
cosA = (float)Math.Cos( p.HeadYawRadians );
sinA = (float)Math.Sin( p.HeadYawRadians );
DrawRotate( 0, 24/16f, 0, -p.PitchRadians, 0, 0, Head ); DrawRotate( 0, 24/16f, 0, -p.PitchRadians, 0, 0, Head );
cosA = (float)Math.Cos( p.YawRadians );
sinA = (float)Math.Sin( p.YawRadians );
DrawPart( Torso ); DrawPart( Torso );
DrawRotate( 0, 12/16f, 0, p.legXRot, 0, 0, LeftLeg ); DrawRotate( 0, 12/16f, 0, p.legXRot, 0, 0, LeftLeg );
DrawRotate( 0, 12/16f, 0, -p.legXRot, 0, 0, RightLeg ); DrawRotate( 0, 12/16f, 0, -p.legXRot, 0, 0, RightLeg );

View File

@ -13,7 +13,7 @@ namespace ClassicalSharp {
public override void SendPlayerClick( MouseButton button, bool buttonDown, byte targetId, PickedPos pos ) { public override void SendPlayerClick( MouseButton button, bool buttonDown, byte targetId, PickedPos pos ) {
Player p = game.LocalPlayer; Player p = game.LocalPlayer;
MakePlayerClick( (byte)button, buttonDown, p.YawDegrees, p.PitchDegrees, targetId, MakePlayerClick( (byte)button, buttonDown, p.HeadYawDegrees, p.PitchDegrees, targetId,
pos.BlockPos, pos.BlockFace ); pos.BlockPos, pos.BlockFace );
SendPacket(); SendPacket();
} }

View File

@ -283,7 +283,7 @@ namespace ClassicalSharp {
if( entityId == 0xFF ) { if( entityId == 0xFF ) {
LocalPlayer p = game.LocalPlayer; LocalPlayer p = game.LocalPlayer;
p.SpawnPoint = p.Position; p.SpawnPoint = p.Position;
p.SpawnYaw = p.YawDegrees; p.SpawnYaw = p.HeadYawDegrees;
p.SpawnPitch = p.PitchDegrees; p.SpawnPitch = p.PitchDegrees;
} }
} }

View File

@ -149,7 +149,7 @@ namespace ClassicalSharp {
Player player = game.LocalPlayer; Player player = game.LocalPlayer;
if( receivedFirstPosition ) { if( receivedFirstPosition ) {
SendPosition( player.Position, player.YawDegrees, player.PitchDegrees ); SendPosition( player.Position, player.HeadYawDegrees, player.PitchDegrees );
} }
CheckForNewTerrainAtlas(); CheckForNewTerrainAtlas();
CheckForWomEnvironment(); CheckForWomEnvironment();

View File

@ -15,8 +15,8 @@ namespace ClassicalSharp {
// \ / and ray origin and direction *---* with the rotated ray // \ / and ray origin and direction *---* with the rotated ray
// * / // * /
// / // /
Vector3 rotatedOrigin = target.Position + Utils.RotateY( origin - target.Position, -target.YawRadians ); Vector3 rotatedOrigin = target.Position + Utils.RotateY( origin - target.Position, -target.HeadYawRadians );
Vector3 rotatedDir = Utils.RotateY( dir, -target.YawRadians ); Vector3 rotatedDir = Utils.RotateY( dir, -target.HeadYawRadians );
BoundingBox bb = target.PickingBounds; BoundingBox bb = target.PickingBounds;
return RayIntersectsBox( rotatedOrigin, rotatedDir, bb.Min, bb.Max, out tMin, out tMax ); return RayIntersectsBox( rotatedOrigin, rotatedDir, bb.Min, bb.Max, out tMin, out tMax );
} }

View File

@ -276,10 +276,10 @@ namespace ClassicalSharp {
LocalPlayer p = game.LocalPlayer; LocalPlayer p = game.LocalPlayer;
Vector3 cameraPos = game.CurrentCameraPos; Vector3 cameraPos = game.CurrentCameraPos;
if( chunksUpdatedThisFrame == 0 && cameraPos == lastCamPos if( chunksUpdatedThisFrame == 0 && cameraPos == lastCamPos
&& p.YawDegrees == lastYaw && p.PitchDegrees == lastPitch ) return; && p.HeadYawDegrees == lastYaw && p.PitchDegrees == lastPitch ) return;
lastCamPos = cameraPos; lastCamPos = cameraPos;
lastYaw = p.YawDegrees; lastPitch = p.PitchDegrees; lastYaw = p.HeadYawDegrees; lastPitch = p.PitchDegrees;
RecalcBooleans( false ); RecalcBooleans( false );
} }
Vector3 lastCamPos; Vector3 lastCamPos;

View File

@ -54,7 +54,7 @@ namespace ClassicalSharp {
} }
public override void GetPickedBlock( PickedPos pos ) { public override void GetPickedBlock( PickedPos pos ) {
Vector3 dir = Utils.GetDirVector( player.YawRadians, player.PitchRadians ); Vector3 dir = Utils.GetDirVector( player.HeadYawRadians, player.PitchRadians );
Vector3 eyePos = player.EyePosition; Vector3 eyePos = player.EyePosition;
float reach = game.LocalPlayer.ReachDistance; float reach = game.LocalPlayer.ReachDistance;
Picking.CalculatePickedBlock( game, eyePos, dir, reach, pos ); Picking.CalculatePickedBlock( game, eyePos, dir, reach, pos );
@ -142,7 +142,7 @@ namespace ClassicalSharp {
Vector3 eyePos = player.EyePosition; Vector3 eyePos = player.EyePosition;
eyePos.Y += bobYOffset; eyePos.Y += bobYOffset;
Vector3 dir = -Utils.GetDirVector( player.YawRadians, player.PitchRadians ); Vector3 dir = -Utils.GetDirVector( player.HeadYawRadians, player.PitchRadians );
Picking.ClipCameraPos( game, eyePos, dir, distance, game.CameraClipPos ); Picking.ClipCameraPos( game, eyePos, dir, distance, game.CameraClipPos );
Vector3 cameraPos = game.CameraClipPos.IntersectPoint; Vector3 cameraPos = game.CameraClipPos.IntersectPoint;
return Matrix4.LookAt( cameraPos, eyePos, Vector3.UnitY ) * tiltMatrix; return Matrix4.LookAt( cameraPos, eyePos, Vector3.UnitY ) * tiltMatrix;
@ -153,7 +153,7 @@ namespace ClassicalSharp {
} }
public override Vector3 GetCameraPos( Vector3 eyePos ) { public override Vector3 GetCameraPos( Vector3 eyePos ) {
Vector3 dir = -Utils.GetDirVector( player.YawRadians, player.PitchRadians ); Vector3 dir = -Utils.GetDirVector( player.HeadYawRadians, player.PitchRadians );
Picking.ClipCameraPos( game, eyePos, dir, distance, game.CameraClipPos ); Picking.ClipCameraPos( game, eyePos, dir, distance, game.CameraClipPos );
return game.CameraClipPos.IntersectPoint; return game.CameraClipPos.IntersectPoint;
} }
@ -176,7 +176,7 @@ namespace ClassicalSharp {
Vector3 eyePos = player.EyePosition; Vector3 eyePos = player.EyePosition;
eyePos.Y += bobYOffset; eyePos.Y += bobYOffset;
Vector3 dir = Utils.GetDirVector( player.YawRadians, player.PitchRadians ); Vector3 dir = Utils.GetDirVector( player.HeadYawRadians, player.PitchRadians );
Picking.ClipCameraPos( game, eyePos, dir, distance, game.CameraClipPos ); Picking.ClipCameraPos( game, eyePos, dir, distance, game.CameraClipPos );
Vector3 cameraPos = game.CameraClipPos.IntersectPoint; Vector3 cameraPos = game.CameraClipPos.IntersectPoint;
return Matrix4.LookAt( cameraPos, eyePos, Vector3.UnitY ) * tiltMatrix; return Matrix4.LookAt( cameraPos, eyePos, Vector3.UnitY ) * tiltMatrix;
@ -187,7 +187,7 @@ namespace ClassicalSharp {
} }
public override Vector3 GetCameraPos( Vector3 eyePos ) { public override Vector3 GetCameraPos( Vector3 eyePos ) {
Vector3 dir = Utils.GetDirVector( player.YawRadians, player.PitchRadians ); Vector3 dir = Utils.GetDirVector( player.HeadYawRadians, player.PitchRadians );
Picking.ClipCameraPos( game, eyePos, dir, distance, game.CameraClipPos ); Picking.ClipCameraPos( game, eyePos, dir, distance, game.CameraClipPos );
return game.CameraClipPos.IntersectPoint; return game.CameraClipPos.IntersectPoint;
} }
@ -202,7 +202,7 @@ namespace ClassicalSharp {
CalcViewBobbing( delta ); CalcViewBobbing( delta );
Vector3 eyePos = player.EyePosition; Vector3 eyePos = player.EyePosition;
eyePos.Y += bobYOffset; eyePos.Y += bobYOffset;
Vector3 cameraDir = Utils.GetDirVector( player.YawRadians, player.PitchRadians ); Vector3 cameraDir = Utils.GetDirVector( player.HeadYawRadians, player.PitchRadians );
return Matrix4.LookAt( eyePos, eyePos + cameraDir, Vector3.UnitY ) * tiltMatrix; return Matrix4.LookAt( eyePos, eyePos + cameraDir, Vector3.UnitY ) * tiltMatrix;
} }