Permalink
Browse files

Scale before rotation for models

  • Loading branch information...
UnknownShadow200 committed Nov 12, 2017
1 parent 8c7e047 commit 4d2305355903e51a1714b8c8973ffd5800203935
Showing with 7 additions and 5 deletions.
  1. +5 −3 ClassicalSharp/Entities/Entity.cs
  2. +2 −2 src/Client/Entity.c
@@ -90,15 +90,15 @@ public abstract class Entity {
public Matrix4 TransformMatrix(Vector3 scale, Vector3 pos) {
Matrix4 m = Matrix4.Identity, tmp;
Matrix4.Scale(out tmp, scale.X, scale.Y, scale.Z);
Matrix4.Mult(out m, ref m, ref tmp);
Matrix4.RotateZ(out tmp, -RotZ * Utils.Deg2Rad);
Matrix4.Mult(out m, ref m, ref tmp);
Matrix4.RotateX(out tmp, -RotX * Utils.Deg2Rad);
Matrix4.Mult(out m, ref m, ref tmp);
Matrix4.RotateY(out tmp, -RotY * Utils.Deg2Rad);
Matrix4.Mult(out m, ref m, ref tmp);
Matrix4.Scale(out tmp, scale.X, scale.Y, scale.Z);
Matrix4.Mult(out m, ref m, ref tmp);
Matrix4.Translate(out tmp, pos.X, pos.Y, pos.Z);
Matrix4.Mult(out m, ref m, ref tmp);
@@ -226,6 +226,8 @@ public abstract class Entity {
/// bounding box of this entity are water or still water. </summary>
public bool TouchesAnyWater() {
AABB bounds = Bounds.Offset(liqExpand);
bounds.Min.Y += 5f/16f;
bounds.Max.Y -= 5f/16f;
return TouchesAny(bounds, touchesAnyWater);
}
static Predicate<BlockID> touchesAnyWater = IsWater;
View
@@ -64,14 +64,14 @@ void Entity_GetTransform(Entity* entity, Vector3 pos, Vector3 scale) {
*m = Matrix_Identity;
Matrix tmp;
Matrix_Scale(&tmp, scale.X, scale.Y, scale.Z);
Matrix_MulBy(m, &tmp);
Matrix_RotateZ(&tmp, -entity->RotZ * MATH_DEG2RAD);
Matrix_MulBy(m, &tmp);
Matrix_RotateX(&tmp, -entity->RotX * MATH_DEG2RAD);
Matrix_MulBy(m, &tmp);
Matrix_RotateY(&tmp, -entity->RotY * MATH_DEG2RAD);
Matrix_MulBy(m, &tmp);
Matrix_Scale(&tmp, scale.X, scale.Y, scale.Z);
Matrix_MulBy(m, &tmp);
Matrix_Translate(&tmp, pos.X, pos.Y, pos.Z);
Matrix_MulBy(m, &tmp);
/* return rotZ * rotX * rotY * scale * translate; */

0 comments on commit 4d23053

Please sign in to comment.