name now rotates with rotated entity

This commit is contained in:
UnknownShadow200 2017-04-14 16:33:29 +10:00
parent 96c9222c65
commit 913e98926e
8 changed files with 23 additions and 9 deletions

View file

@ -222,7 +222,7 @@ namespace ClassicalSharp.Gui.Screens {
}
}
bool Show(BlockID block) {
bool Show(BlockID block) { return true;
if (game.PureClassic && IsHackBlock(block)) return false;
if (block < Block.CpeCount) {
int count = game.UseCPEBlocks ? Block.CpeCount : Block.OriginalCount;

View file

@ -43,6 +43,7 @@ namespace ClassicalSharp.Entities {
protected internal bool onGround;
internal float StepSize;
internal int tickCount;
internal Matrix4 transform;
public SkinType SkinType;
public AnimatedComponent anim;

View file

@ -51,7 +51,7 @@ namespace ClassicalSharp.Model {
public override float ShadowScale { get { return 0.5f; } }
public override float NameYOffset { get { return (32 - sitOffset)/16f + 0.5f/16f; } }
public override float NameYOffset { get { return 32/16f + 0.5f/16f; } }
public override float GetEyeY(Entity entity) { return (26 - sitOffset)/16f; }
@ -63,7 +63,7 @@ namespace ClassicalSharp.Model {
get { return new AABB(-8/16f, 0, -4/16f, 8/16f, (32 - sitOffset)/16f, 4/16f); }
}
protected override Matrix4 TransformMatrix(Entity p, Vector3 pos) {
protected internal override Matrix4 TransformMatrix(Entity p, Vector3 pos) {
pos.Y -= (sitOffset / 16f) * p.ModelScale;
return p.TransformMatrix(p.ModelScale, pos);
}

View file

@ -110,6 +110,7 @@ namespace ClassicalSharp.Model {
game.Graphics.PushMatrix();
Matrix4 m = TransformMatrix(p, pos);
p.transform = m;
game.Graphics.MultiplyMatrix(ref m);
DrawModel(p);
game.Graphics.PopMatrix();
@ -146,7 +147,7 @@ namespace ClassicalSharp.Model {
public virtual void Dispose() { }
protected virtual Matrix4 TransformMatrix(Entity p, Vector3 pos) {
protected internal virtual Matrix4 TransformMatrix(Entity p, Vector3 pos) {
return p.TransformMatrix(p.ModelScale, pos);
}

View file

@ -81,7 +81,9 @@ namespace ClassicalSharp.Entities {
IGraphicsApi gfx = game.Graphics;
gfx.BindTexture(nameTex.ID);
Vector3 pos = Position; pos.Y += Model.NameYOffset * ModelScale;
Vector3 pos;
Vector3.TransformY(Model.NameYOffset, ref transform, out pos);
float scale = Math.Min(1, Model.NameScale * ModelScale) / 70f;
Vector3 p111, p121, p212, p222;

View file

@ -153,6 +153,20 @@ namespace OpenTK {
result.Y = vec.Y * scale;
result.Z = vec.Z * scale;
}
public static void Transform(ref Vector3 vec, ref Matrix4 mat, out Vector3 result) {
result = new Vector3(
vec.X * mat.Row0.X + vec.Y * mat.Row1.X + vec.Z * mat.Row2.X + mat.Row3.X,
vec.X * mat.Row0.Y + vec.Y * mat.Row1.Y + vec.Z * mat.Row2.Y + mat.Row3.Y,
vec.X * mat.Row0.Z + vec.Y * mat.Row1.Z + vec.Z * mat.Row2.Z + mat.Row3.Z);
}
public static void TransformY(float y, ref Matrix4 mat, out Vector3 result) {
result = new Vector3(
y * mat.Row1.X + mat.Row3.X,
y * mat.Row1.Y + mat.Row3.Y,
y * mat.Row1.Z + mat.Row3.Z);
}
public static Vector3 operator + (Vector3 left, Vector3 right) {
left.X += right.X;

View file

@ -182,7 +182,6 @@
<ClCompile Include="Noise.c" />
<ClCompile Include="NotchyGenerator.c" />
<ClCompile Include="Random.c" />
<ClCompile Include="Test.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View file

@ -56,9 +56,6 @@
<ClCompile Include="Noise.c">
<Filter>Source Files\Generator</Filter>
</ClCompile>
<ClCompile Include="Test.c">
<Filter>Source Files\Generator</Filter>
</ClCompile>
<ClCompile Include="Compiler.c">
<Filter>Source Files\Generator</Filter>
</ClCompile>