mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 03:25:14 -04:00
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:
parent
6621f81cda
commit
bbe3820e95
@ -186,12 +186,12 @@ namespace ClassicalSharp {
|
||||
string value = buffer.GetString();
|
||||
|
||||
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 y = startY - size.Height - 5;
|
||||
|
||||
args.SkipPartsCheck = true;
|
||||
blockInfoTexture = game.Drawer2D.MakeTextTexture( ref args, x, y );
|
||||
blockInfoTexture = game.Drawer2D.MakeChatTextTexture( ref args, x, y );
|
||||
}
|
||||
|
||||
void RecreateBlockTable() {
|
||||
|
@ -116,7 +116,7 @@ namespace ClassicalSharp {
|
||||
|
||||
void AddPlayerInfo( CpeListInfo player, int index ) {
|
||||
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 ) {
|
||||
info[namesCount] = new PlayerInfo( player );
|
||||
textures[namesCount] = tex;
|
||||
@ -159,7 +159,7 @@ namespace ClassicalSharp {
|
||||
|
||||
void AddGroup( string group, ref int index ) {
|
||||
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 );
|
||||
|
||||
PushDown( info, index, pInfo );
|
||||
|
@ -61,7 +61,7 @@ namespace ClassicalSharp {
|
||||
|
||||
void AddPlayerInfo( Player player ) {
|
||||
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 );
|
||||
textures[namesCount] = tex;
|
||||
namesCount++;
|
||||
|
@ -19,12 +19,18 @@ namespace ClassicalSharp {
|
||||
|
||||
public Vector3 Position;
|
||||
public Vector3 Velocity;
|
||||
public float YawDegrees, PitchDegrees;
|
||||
public float HeadYawDegrees, YawDegrees, PitchDegrees;
|
||||
|
||||
protected Game game;
|
||||
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 {
|
||||
get { return YawDegrees * Utils.Deg2Rad; }
|
||||
set { YawDegrees = value * Utils.Rad2Deg; }
|
||||
|
@ -58,7 +58,7 @@ namespace ClassicalSharp {
|
||||
api.AlphaTest = true;
|
||||
LocalPlayer localP = game.LocalPlayer;
|
||||
Vector3 eyePos = localP.EyePosition;
|
||||
Vector3 dir = Utils.GetDirVector( localP.YawRadians, localP.PitchRadians );
|
||||
Vector3 dir = Utils.GetDirVector( localP.HeadYawRadians, localP.PitchRadians );
|
||||
closestId = 255;
|
||||
|
||||
if( NamesMode != NameMode.AllNames )
|
||||
@ -112,7 +112,7 @@ namespace ClassicalSharp {
|
||||
|
||||
public byte GetClosetPlayer( LocalPlayer localP ) {
|
||||
Vector3 eyePos = localP.EyePosition;
|
||||
Vector3 dir = Utils.GetDirVector( localP.YawRadians, localP.PitchRadians );
|
||||
Vector3 dir = Utils.GetDirVector( localP.HeadYawRadians, localP.PitchRadians );
|
||||
float closestDist = float.PositiveInfinity;
|
||||
byte targetId = 255;
|
||||
|
||||
|
@ -140,7 +140,7 @@ namespace ClassicalSharp {
|
||||
if( dist < 1 ) dist = 1;
|
||||
|
||||
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 ) {
|
||||
|
@ -85,24 +85,6 @@ namespace ClassicalSharp {
|
||||
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 );
|
||||
public override void Tick( double delta ) {
|
||||
if( game.Map.IsNotLoaded ) return;
|
||||
@ -132,6 +114,7 @@ namespace ClassicalSharp {
|
||||
game.AudioPlayer.PlayStepSound( type );
|
||||
lastSoundPos = soundPos;
|
||||
}
|
||||
UpdateCurrentBodyYaw();
|
||||
}
|
||||
|
||||
bool DoPlaySound( Vector3 soundPos ) {
|
||||
@ -282,14 +265,55 @@ namespace ClassicalSharp {
|
||||
|
||||
internal Vector3 lastPos, nextPos;
|
||||
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>
|
||||
public void SetInterpPosition( float 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 );
|
||||
}
|
||||
|
||||
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 ) {
|
||||
KeyMap keys = game.InputHandler.Keys;
|
||||
if( key == keys[KeyBinding.Respawn] && CanRespawn && HacksEnabled ) {
|
||||
@ -311,7 +335,7 @@ namespace ClassicalSharp {
|
||||
SetLocation( update, false );
|
||||
} else if( key == keys[KeyBinding.SetSpawn] && CanRespawn && HacksEnabled ) {
|
||||
SpawnPoint = Position;
|
||||
SpawnYaw = YawDegrees;
|
||||
SpawnYaw = HeadYawDegrees;
|
||||
SpawnPitch = PitchDegrees;
|
||||
} else if( key == keys[KeyBinding.Fly] && CanFly && HacksEnabled ) {
|
||||
flying = !flying;
|
||||
|
@ -25,13 +25,14 @@ namespace ClassicalSharp {
|
||||
serverPos = update.RelativePosition ? serverPos + update.Pos : update.Pos;
|
||||
}
|
||||
if( update.IncludesOrientation ) {
|
||||
serverYaw = update.Yaw;
|
||||
serverPitch = update.Pitch;
|
||||
serverYaw = update.Yaw; serverPitch = update.Pitch;
|
||||
}
|
||||
|
||||
if( !interpolate ) {
|
||||
stateCount = 0;
|
||||
newState = oldState = new State( tickCount, serverPos, serverYaw, serverPitch );
|
||||
yawStateCount = 0;
|
||||
newYaw = oldYaw = serverYaw;
|
||||
} else {
|
||||
// Smoother interpolation by also adding midpoint.
|
||||
Vector3 midPos = Vector3.Lerp( lastPos, serverPos, 0.5f );
|
||||
@ -39,25 +40,30 @@ namespace ClassicalSharp {
|
||||
float midPitch = Utils.LerpAngle( lastPitch, serverPitch, 0.5f );
|
||||
AddState( new State( tickCount, midPos, midYaw, midPitch ) );
|
||||
AddState( new State( tickCount, serverPos, serverYaw, serverPitch ) );
|
||||
for( int i = 0; i < 3; i++ )
|
||||
AddYaw( Utils.LerpAngle( lastYaw, serverYaw, (i + 1) / 3f ) );
|
||||
}
|
||||
}
|
||||
|
||||
struct State {
|
||||
public int tick;
|
||||
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.pos = pos;
|
||||
this.yaw = yaw;
|
||||
this.headYaw = headYaw;
|
||||
this.pitch = pitch;
|
||||
}
|
||||
}
|
||||
|
||||
State[] states = new State[10];
|
||||
float[] yawStates = new float[15];
|
||||
State newState, oldState;
|
||||
int stateCount;
|
||||
float newYaw, oldYaw;
|
||||
int stateCount, yawStateCount;
|
||||
|
||||
public override void Tick( double delta ) {
|
||||
CheckSkin();
|
||||
tickCount++;
|
||||
@ -66,30 +72,35 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
void AddState( State state ) {
|
||||
if( stateCount == states.Length )
|
||||
RemoveOldestState();
|
||||
states[stateCount++] = state;
|
||||
if( stateCount == states.Length )
|
||||
RemoveOldest( states, ref stateCount );
|
||||
states[stateCount++] = state;
|
||||
}
|
||||
|
||||
void RemoveOldestState() {
|
||||
for( int i = 0; i < states.Length - 1; i++ ) {
|
||||
states[i] = states[i + 1];
|
||||
}
|
||||
stateCount--;
|
||||
void AddYaw( float state ) {
|
||||
if( yawStateCount == yawStates.Length )
|
||||
RemoveOldest( yawStates, ref yawStateCount );
|
||||
yawStates[yawStateCount++] = state;
|
||||
}
|
||||
|
||||
void UpdateCurrentState() {
|
||||
oldState = newState;
|
||||
if( stateCount == 0 ) return;
|
||||
|
||||
//if( states[0].tick > tickCount - 2 ) return; // 100 ms delay
|
||||
newState = states[0];
|
||||
RemoveOldestState();
|
||||
oldYaw = newYaw;
|
||||
if( stateCount > 0 ) {
|
||||
//if( states[0].tick > tickCount - 2 ) return; // 100 ms delay
|
||||
newState = states[0];
|
||||
RemoveOldest( states, ref stateCount );
|
||||
}
|
||||
if( yawStateCount > 0 ) {
|
||||
newYaw = yawStates[0];
|
||||
RemoveOldest( yawStates, ref yawStateCount );
|
||||
}
|
||||
}
|
||||
|
||||
public override void RenderModel( double deltaTime, float 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 );
|
||||
|
||||
GetCurrentAnimState( t );
|
||||
|
@ -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--;
|
||||
}
|
||||
}
|
||||
}
|
@ -70,6 +70,8 @@ namespace ClassicalSharp.Model {
|
||||
block = Byte.Parse( p.ModelName );
|
||||
}
|
||||
|
||||
cosA = (float)Math.Cos( p.YawRadians );
|
||||
sinA = (float)Math.Sin( p.YawRadians );
|
||||
CalcState( block );
|
||||
if( game.BlockInfo.IsAir[block] )
|
||||
return;
|
||||
|
@ -56,9 +56,14 @@ namespace ClassicalSharp.Model {
|
||||
int texId = p.MobTextureId <= 0 ? cache.ChickenTexId : p.MobTextureId;
|
||||
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, Head2 );
|
||||
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 );
|
||||
DrawRotate( 0, 5/16f, 1/16f, p.legXRot, 0, 0, LeftLeg );
|
||||
DrawRotate( 0, 5/16f, 1/16f, -p.legXRot, 0, 0, RightLeg );
|
||||
|
@ -46,8 +46,12 @@ namespace ClassicalSharp.Model {
|
||||
protected override void DrawPlayerModel( Player p ) {
|
||||
int texId = p.MobTextureId <= 0 ? cache.CreeperTexId : p.MobTextureId;
|
||||
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 );
|
||||
|
||||
cosA = (float)Math.Cos( p.YawRadians );
|
||||
sinA = (float)Math.Sin( p.YawRadians );
|
||||
DrawPart( Torso );
|
||||
DrawRotate( 0, 6/16f, -2/16f, p.legXRot, 0, 0, LeftLegFront );
|
||||
DrawRotate( 0, 6/16f, -2/16f, -p.legXRot, 0, 0, RightLegFront );
|
||||
|
@ -51,8 +51,6 @@ namespace ClassicalSharp.Model {
|
||||
pos = p.Position;
|
||||
if( Bobbing )
|
||||
pos.Y += p.bobYOffset;
|
||||
cosA = (float)Math.Cos( p.YawRadians );
|
||||
sinA = (float)Math.Sin( p.YawRadians );
|
||||
Map map = game.Map;
|
||||
col = game.Map.IsLit( Vector3I.Floor( p.EyePosition ) ) ? map.Sunlight : map.Shadowlight;
|
||||
|
||||
|
@ -45,8 +45,12 @@ namespace ClassicalSharp.Model {
|
||||
protected override void DrawPlayerModel( Player p ) {
|
||||
int texId = p.MobTextureId <= 0 ? cache.PigTexId : p.MobTextureId;
|
||||
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 );
|
||||
|
||||
cosA = (float)Math.Cos( p.YawRadians );
|
||||
sinA = (float)Math.Sin( p.YawRadians );
|
||||
DrawPart( Torso );
|
||||
DrawRotate( 0, 6/16f, -5/16f, p.legXRot, 0, 0, LeftLegFront );
|
||||
DrawRotate( 0, 6/16f, -5/16f, -p.legXRot, 0, 0, RightLegFront );
|
||||
|
@ -68,8 +68,12 @@ namespace ClassicalSharp.Model {
|
||||
SkinType skinType = p.SkinType;
|
||||
_64x64 = skinType != SkinType.Type64x32;
|
||||
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 );
|
||||
|
||||
cosA = (float)Math.Cos( p.YawRadians );
|
||||
sinA = (float)Math.Sin( p.YawRadians );
|
||||
DrawPart( model.Torso );
|
||||
DrawRotate( 0, 12/16f, 0, p.legXRot, 0, 0, model.LeftLeg );
|
||||
DrawRotate( 0, 12/16f, 0, -p.legXRot, 0, 0, model.RightLeg );
|
||||
@ -81,6 +85,8 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
graphics.AlphaTest = true;
|
||||
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 );
|
||||
graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ namespace ClassicalSharp.Model {
|
||||
.SetTexOrigin( 0, 0 )
|
||||
.SetModelBounds( -3.5f, 15.5f, -12.5f, 3.5f, 22.5f, -5.5f ) );
|
||||
FurTorso = BuildRotatedBox( MakeRotatedBoxBounds( -4, 12, -8, 4, 18, 8 )
|
||||
.SetTexOrigin( 28, 8 )
|
||||
.SetModelBounds( -6f, 10.5f, -10f, 6f, 19.5f, 10f ) );
|
||||
.SetTexOrigin( 28, 8 )
|
||||
.SetModelBounds( -6f, 10.5f, -10f, 6f, 19.5f, 10f ) );
|
||||
BoxDescription legDesc = MakeBoxBounds( -2, -3, -2, 2, 3, 2 )
|
||||
.SetTexOrigin( 0, 16 );
|
||||
|
||||
@ -67,8 +67,12 @@ namespace ClassicalSharp.Model {
|
||||
protected override void DrawPlayerModel( Player p ) {
|
||||
int texId = p.MobTextureId <= 0 ? cache.SheepTexId : p.MobTextureId;
|
||||
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 );
|
||||
|
||||
cosA = (float)Math.Cos( p.YawRadians );
|
||||
sinA = (float)Math.Sin( p.YawRadians );
|
||||
DrawPart( Torso );
|
||||
DrawRotate( 0, 12/16f, -5/16f, p.legXRot, 0, 0, LeftLegFront );
|
||||
DrawRotate( 0, 12/16f, -5/16f, -p.legXRot, 0, 0, RightLegFront );
|
||||
@ -79,8 +83,13 @@ namespace ClassicalSharp.Model {
|
||||
|
||||
if( Fur ) {
|
||||
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 );
|
||||
|
||||
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, FurRightLegFront );
|
||||
DrawRotate( 0, 12/16f, 7/16f, -p.legXRot, 0, 0, FurLeftLegBack );
|
||||
|
@ -45,8 +45,12 @@ namespace ClassicalSharp.Model {
|
||||
protected override void DrawPlayerModel( Player p ) {
|
||||
int texId = p.MobTextureId <= 0 ? cache.SkeletonTexId : p.MobTextureId;
|
||||
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 );
|
||||
|
||||
cosA = (float)Math.Cos( p.YawRadians );
|
||||
sinA = (float)Math.Sin( p.YawRadians );
|
||||
DrawPart( Torso );
|
||||
DrawRotate( 0, 12/16f, 0, p.legXRot, 0, 0, LeftLeg );
|
||||
DrawRotate( 0, 12/16f, 0, -p.legXRot, 0, 0, RightLeg );
|
||||
|
@ -45,11 +45,14 @@ namespace ClassicalSharp.Model {
|
||||
protected override void DrawPlayerModel( Player p ) {
|
||||
int texId = p.MobTextureId <= 0 ? cache.SpiderTexId : p.MobTextureId;
|
||||
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 );
|
||||
|
||||
cosA = (float)Math.Cos( p.YawRadians );
|
||||
sinA = (float)Math.Sin( p.YawRadians );
|
||||
DrawPart( Link );
|
||||
DrawPart( End );
|
||||
|
||||
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 rotY = (float)(Math.Sin( p.walkTime * 2 ) * p.swing * Math.PI / 32f);
|
||||
|
@ -45,8 +45,12 @@ namespace ClassicalSharp.Model {
|
||||
protected override void DrawPlayerModel( Player p ) {
|
||||
int texId = p.MobTextureId <= 0 ? cache.ZombieTexId : p.MobTextureId;
|
||||
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 );
|
||||
|
||||
cosA = (float)Math.Cos( p.YawRadians );
|
||||
sinA = (float)Math.Sin( p.YawRadians );
|
||||
DrawPart( Torso );
|
||||
DrawRotate( 0, 12/16f, 0, p.legXRot, 0, 0, LeftLeg );
|
||||
DrawRotate( 0, 12/16f, 0, -p.legXRot, 0, 0, RightLeg );
|
||||
|
@ -13,7 +13,7 @@ namespace ClassicalSharp {
|
||||
|
||||
public override void SendPlayerClick( MouseButton button, bool buttonDown, byte targetId, PickedPos pos ) {
|
||||
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 );
|
||||
SendPacket();
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ namespace ClassicalSharp {
|
||||
if( entityId == 0xFF ) {
|
||||
LocalPlayer p = game.LocalPlayer;
|
||||
p.SpawnPoint = p.Position;
|
||||
p.SpawnYaw = p.YawDegrees;
|
||||
p.SpawnYaw = p.HeadYawDegrees;
|
||||
p.SpawnPitch = p.PitchDegrees;
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ namespace ClassicalSharp {
|
||||
|
||||
Player player = game.LocalPlayer;
|
||||
if( receivedFirstPosition ) {
|
||||
SendPosition( player.Position, player.YawDegrees, player.PitchDegrees );
|
||||
SendPosition( player.Position, player.HeadYawDegrees, player.PitchDegrees );
|
||||
}
|
||||
CheckForNewTerrainAtlas();
|
||||
CheckForWomEnvironment();
|
||||
|
@ -15,8 +15,8 @@ namespace ClassicalSharp {
|
||||
// \ / and ray origin and direction *---* with the rotated ray
|
||||
// * /
|
||||
// /
|
||||
Vector3 rotatedOrigin = target.Position + Utils.RotateY( origin - target.Position, -target.YawRadians );
|
||||
Vector3 rotatedDir = Utils.RotateY( dir, -target.YawRadians );
|
||||
Vector3 rotatedOrigin = target.Position + Utils.RotateY( origin - target.Position, -target.HeadYawRadians );
|
||||
Vector3 rotatedDir = Utils.RotateY( dir, -target.HeadYawRadians );
|
||||
BoundingBox bb = target.PickingBounds;
|
||||
return RayIntersectsBox( rotatedOrigin, rotatedDir, bb.Min, bb.Max, out tMin, out tMax );
|
||||
}
|
||||
|
@ -276,10 +276,10 @@ namespace ClassicalSharp {
|
||||
LocalPlayer p = game.LocalPlayer;
|
||||
Vector3 cameraPos = game.CurrentCameraPos;
|
||||
if( chunksUpdatedThisFrame == 0 && cameraPos == lastCamPos
|
||||
&& p.YawDegrees == lastYaw && p.PitchDegrees == lastPitch ) return;
|
||||
&& p.HeadYawDegrees == lastYaw && p.PitchDegrees == lastPitch ) return;
|
||||
|
||||
lastCamPos = cameraPos;
|
||||
lastYaw = p.YawDegrees; lastPitch = p.PitchDegrees;
|
||||
lastYaw = p.HeadYawDegrees; lastPitch = p.PitchDegrees;
|
||||
RecalcBooleans( false );
|
||||
}
|
||||
Vector3 lastCamPos;
|
||||
|
@ -54,7 +54,7 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
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;
|
||||
float reach = game.LocalPlayer.ReachDistance;
|
||||
Picking.CalculatePickedBlock( game, eyePos, dir, reach, pos );
|
||||
@ -142,7 +142,7 @@ namespace ClassicalSharp {
|
||||
Vector3 eyePos = player.EyePosition;
|
||||
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 );
|
||||
Vector3 cameraPos = game.CameraClipPos.IntersectPoint;
|
||||
return Matrix4.LookAt( cameraPos, eyePos, Vector3.UnitY ) * tiltMatrix;
|
||||
@ -153,7 +153,7 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
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 );
|
||||
return game.CameraClipPos.IntersectPoint;
|
||||
}
|
||||
@ -176,7 +176,7 @@ namespace ClassicalSharp {
|
||||
Vector3 eyePos = player.EyePosition;
|
||||
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 );
|
||||
Vector3 cameraPos = game.CameraClipPos.IntersectPoint;
|
||||
return Matrix4.LookAt( cameraPos, eyePos, Vector3.UnitY ) * tiltMatrix;
|
||||
@ -187,7 +187,7 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
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 );
|
||||
return game.CameraClipPos.IntersectPoint;
|
||||
}
|
||||
@ -202,7 +202,7 @@ namespace ClassicalSharp {
|
||||
CalcViewBobbing( delta );
|
||||
Vector3 eyePos = player.EyePosition;
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user