diff --git a/ClassicalSharp/Entities/Components/InputComponent.cs b/ClassicalSharp/Entities/Components/InputComponent.cs index 2e14f7b6f..5f329ef4e 100644 --- a/ClassicalSharp/Entities/Components/InputComponent.cs +++ b/ClassicalSharp/Entities/Components/InputComponent.cs @@ -60,7 +60,7 @@ namespace ClassicalSharp.Entities { void FindHighestFree( ref Vector3 spawn ) { BlockInfo info = game.BlockInfo; - Vector3 size = entity.Model.CollisionSize; + Vector3 size = entity.CollisionSize; BoundingBox bb = entity.CollisionBounds; Vector3I P = Vector3I.Floor( spawn ); int bbMax = Utils.Floor( size.Y ); diff --git a/ClassicalSharp/Entities/Entity.Bounds.cs b/ClassicalSharp/Entities/Entity.Bounds.cs index 1bc69c83e..0bc6ace46 100644 --- a/ClassicalSharp/Entities/Entity.Bounds.cs +++ b/ClassicalSharp/Entities/Entity.Bounds.cs @@ -11,7 +11,9 @@ namespace ClassicalSharp.Entities { /// Returns the bounding box that contains the model, assuming it is not rotated. public BoundingBox PickingBounds { - get { UpdateModel(); return Model.PickingBounds.Offset( Position ); } + get { UpdateModel(); BoundingBox bb = Model.PickingBounds; + return bb.Scale( ModelScale ).Offset( Position ); + } } /// Bounding box of the model that collision detection diff --git a/ClassicalSharp/Entities/Entity.cs b/ClassicalSharp/Entities/Entity.cs index da849be34..b8bfc1d39 100644 --- a/ClassicalSharp/Entities/Entity.cs +++ b/ClassicalSharp/Entities/Entity.cs @@ -48,7 +48,7 @@ namespace ClassicalSharp.Entities { /// Returns the size of the model that is used for collision detection. public Vector3 CollisionSize { - get { UpdateModel(); return Model.CollisionSize; } + get { UpdateModel(); return Model.CollisionSize * ModelScale; } } void UpdateModel() { @@ -72,7 +72,8 @@ namespace ClassicalSharp.Entities { /// Gets the position of the player's eye in the world. public Vector3 EyePosition { - get { return new Vector3( Position.X, Position.Y + Model.GetEyeY( this ), Position.Z ); } + get { return new Vector3( Position.X, + Position.Y + Model.GetEyeY( this ) * ModelScale, Position.Z ); } } /// Gets the block just underneath the player's feet position. diff --git a/ClassicalSharp/Entities/Player.cs b/ClassicalSharp/Entities/Player.cs index 2ea542201..249c4d220 100644 --- a/ClassicalSharp/Entities/Player.cs +++ b/ClassicalSharp/Entities/Player.cs @@ -47,7 +47,7 @@ namespace ClassicalSharp.Entities { if( !float.TryParse( scale, out value ) || float.IsNaN( value ) ) return; - Utils.Clamp( ref value, 0.1f, Model.MaxScale ); + Utils.Clamp( ref value, 0.25f, Model.MaxScale ); ModelScale = value; } @@ -77,7 +77,7 @@ namespace ClassicalSharp.Entities { IGraphicsApi api = game.Graphics; api.BindTexture( nameTex.ID ); - Vector3 pos = Position; pos.Y += Model.NameYOffset; + Vector3 pos = Position; pos.Y += Model.NameYOffset * ModelScale; Vector3 p111, p121, p212, p222; FastColour col = FastColour.White; diff --git a/ClassicalSharp/Model/BlockModel.cs b/ClassicalSharp/Model/BlockModel.cs index 06527be05..a0e269f77 100644 --- a/ClassicalSharp/Model/BlockModel.cs +++ b/ClassicalSharp/Model/BlockModel.cs @@ -212,6 +212,7 @@ namespace ClassicalSharp.Model { for( int i = 0; i < index; i++ ) { VertexP3fT2fC4b v = cache.vertices[i]; float t = cosYaw * v.X - sinYaw * v.Z; v.Z = sinYaw * v.X + cosYaw * v.Z; v.X = t; // Inlined RotY + v.X *= scale; v.Y *= scale; v.Z *= scale; v.X += pos.X; v.Y += pos.Y; v.Z += pos.Z; cache.vertices[i] = v; } diff --git a/ClassicalSharp/Model/HumanModels.cs b/ClassicalSharp/Model/HumanModels.cs index 74ea1c57e..731ab743a 100644 --- a/ClassicalSharp/Model/HumanModels.cs +++ b/ClassicalSharp/Model/HumanModels.cs @@ -25,6 +25,8 @@ namespace ClassicalSharp.Model { offset = 0.5f * 0.5f; } + public override float MaxScale { get { return 3; } } + public override float NameYOffset { get { return 1.3875f; } } public override float GetEyeY( Entity entity ) { return 14/16f; } @@ -40,28 +42,30 @@ namespace ClassicalSharp.Model { public class GiantModel : HumanoidModel { - const float scale = 2f; + const float size = 2f; public GiantModel( Game window ) : base( window ) { } protected override void MakeDescriptions() { base.MakeDescriptions(); - head = head.Scale( scale ); torso = torso.Scale( scale ); - lLeg = lLeg.Scale( scale ); rLeg = rLeg.Scale( scale ); - lArm = lArm.Scale( scale ); rArm = rArm.Scale( scale ); - offset = 0.5f * scale; + head = head.Scale( size ); torso = torso.Scale( size ); + lLeg = lLeg.Scale( size ); rLeg = rLeg.Scale( size ); + lArm = lArm.Scale( size ); rArm = rArm.Scale( size ); + offset = 0.5f * size; } - - public override float NameYOffset { get { return 2 * scale + 0.1375f; } } - public override float GetEyeY( Entity entity ) { return base.GetEyeY( entity ) * scale; } + public override float MaxScale { get { return 1; } } + + public override float NameYOffset { get { return 2 * size + 0.1375f; } } + + public override float GetEyeY( Entity entity ) { return base.GetEyeY( entity ) * size; } public override Vector3 CollisionSize { - get { return new Vector3( 8/16f * scale + 0.6f/16f, - 28.1f/16f * scale, 8/16f * scale + 0.6f/16f ); } + get { return new Vector3( 8/16f * size + 0.6f/16f, + 28.1f/16f * size, 8/16f * size + 0.6f/16f ); } } public override BoundingBox PickingBounds { - get { return base.PickingBounds.Scale( scale ); } + get { return base.PickingBounds.Scale( size ); } } } } diff --git a/ClassicalSharp/Model/IModel.cs b/ClassicalSharp/Model/IModel.cs index df2a60784..3187be6a9 100644 --- a/ClassicalSharp/Model/IModel.cs +++ b/ClassicalSharp/Model/IModel.cs @@ -37,8 +37,8 @@ namespace ClassicalSharp.Model { /// Vertical offset from the model's feet/base that the model's eye is located. public abstract float GetEyeY( Entity entity ); - /// The maximum scale the entity can have (for collisions and rendering). - public virtual float MaxScale { get { return 1; } } + /// The maximum scale the entity can have (for collisions and rendering). + public virtual float MaxScale { get { return 2; } } /// The size of the bounding box that is used when /// performing collision detection for this model. @@ -50,7 +50,7 @@ namespace ClassicalSharp.Model { protected Vector3 pos; protected float cosYaw, sinYaw, cosHead, sinHead; - protected float uScale, vScale; + protected float uScale, vScale, scale; /// Renders the model based on the given entity's position and orientation. public void Render( Player p ) { @@ -60,6 +60,7 @@ namespace ClassicalSharp.Model { World map = game.World; col = game.World.IsLit( Vector3I.Floor( p.EyePosition ) ) ? map.Sunlight : map.Shadowlight; uScale = 1 / 64f; vScale = 1 / 32f; + scale = p.ModelScale; cols[0] = col; cols[1] = FastColour.Scale( col, FastColour.ShadeYBottom ); @@ -105,6 +106,7 @@ namespace ClassicalSharp.Model { for( int i = 0; i < part.Count; i++ ) { ModelVertex v = vertices[part.Offset + i]; float t = cosYaw * v.X - sinYaw * v.Z; v.Z = sinYaw * v.X + cosYaw * v.Z; v.X = t; // Inlined RotY + v.X *= scale; v.Y *= scale; v.Z *= scale; v.X += pos.X; v.Y += pos.Y; v.Z += pos.Z; FastColour col = part.Count == boxVertices ? @@ -161,6 +163,7 @@ namespace ClassicalSharp.Model { t = cosYaw * tX - sinYaw * tZ; tZ = sinYaw * tX + cosYaw * tZ; tX = t; // Inlined RotY v.X += tX; v.Y += y; v.Z += tZ; } + v.X *= scale; v.Y *= scale; v.Z *= scale; v.X += pos.X; v.Y += pos.Y; v.Z += pos.Z; FastColour col = part.Count == boxVertices ?