give zombie/skeleton/chibi model proper arms. other models no longer show an arm.

This commit is contained in:
UnknownShadow200 2018-07-31 20:23:04 +10:00
parent 4832e7d37c
commit 0f2327ea8a
13 changed files with 185 additions and 182 deletions

View File

@ -23,6 +23,7 @@ namespace ClassicalSharp.Model {
lArm = lArm.Scale(size);
rArm = rArm.Scale(size);
offset = 0.5f * size;
armX = 3; armY = 6;
}
public override float NameYOffset { get { return 20.2f/16; } }
@ -110,77 +111,10 @@ namespace ClassicalSharp.Model {
DrawRotate(-p.HeadXRadians, 0, 0, part, true);
UpdateVB();
}
public override void DrawArm(Entity p) { }
}
public class ArmModel : HumanoidModel {
Matrix4 translate;
bool classicArms;
public ArmModel(Game game) : base(game) { Pushes = false; }
public override void CreateParts() {
classicArms = game.ClassicArmModel;
SetTranslationMatrix();
}
void SetTranslationMatrix() {
if (game.ClassicArmModel) {
// TODO: Position's not quite right.
// Matrix4.Translate(out m, -6 / 16f + 0.2f, -12 / 16f - 0.20f, 0);
// is better, but that breaks the dig animation
Matrix4.Translate(out translate, -6 / 16f, -12 / 16f - 0.10f, 0);
} else {
Matrix4.Translate(out translate, -6 / 16f + 0.10f, -12 / 16f - 0.26f, 0);
}
}
public override float NameYOffset { get { return 0.5f; } }
public override float GetEyeY(Entity entity) { return 0.5f; }
public override Vector3 CollisionSize { get { return Vector3.One; } }
public override AABB PickingBounds { get { return new AABB(-0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f); } }
protected override void RenderParts(Entity p) {
HumanoidModel human = (HumanoidModel)game.ModelCache.Models[0].Instance;
vertices = human.vertices;
// If user changes option while game is running
if (classicArms != game.ClassicArmModel) {
classicArms = game.ClassicArmModel;
SetTranslationMatrix();
}
Matrix4 m;
Matrix4.Mult(out m, ref p.transform, ref game.Graphics.View);
Matrix4.Mult(out m, ref translate, ref m);
game.Graphics.LoadMatrix(ref m);
SkinType skinType = p.SkinType;
ModelSet model = skinType == SkinType.Type64x64Slim ? human.SetSlim :
(skinType == SkinType.Type64x64 ? human.Set64 : human.Set);
Rotate = RotateOrder.YZX;
DrawArmPart(model.RightArm);
UpdateVB();
if (skinType != SkinType.Type64x32) {
index = 0;
game.Graphics.AlphaTest = true;
DrawArmPart(model.RightArmLayer);
UpdateVB();
game.Graphics.AlphaTest = false;
}
Rotate = RotateOrder.ZYX;
}
void DrawArmPart(ModelPart part) {
part.RotX += 1 / 16.0f; part.RotY -= 4 / 16.0f;
if (game.ClassicArmModel) {
DrawRotate(0, -90 * Utils.Deg2Rad, 120 * Utils.Deg2Rad, part, false);
} else {
DrawRotate(-20 * Utils.Deg2Rad, -70 * Utils.Deg2Rad, 135 * Utils.Deg2Rad, part, false);
}
}
}
public class CorpseModel : IModel {
public CorpseModel(Game game) : base(game) {
@ -211,5 +145,9 @@ namespace ClassicalSharp.Model {
model.SetupState(p);
model.DrawModel(p);
}
public override void DrawArm(Entity p) {
game.ModelCache.Models[0].Instance.DrawArm(p);
}
}
}

View File

@ -121,6 +121,18 @@ namespace ClassicalSharp.Model {
UpdateVB();
}
public override void DrawArm(Entity p) {
SkinType skin = p.SkinType;
ModelSet model = skin == SkinType.Type64x64Slim ? SetSlim :
(skin == SkinType.Type64x64 ? Set64 : Set);
DrawArmPart(model.RightArm);
if (skin != SkinType.Type64x32) {
DrawArmPart(model.RightArmLayer);
}
UpdateVB();
}
public class ModelSet {
public ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm, Hat,
TorsoLayer, LeftLegLayer, RightLegLayer, LeftArmLayer, RightArmLayer;

View File

@ -17,7 +17,7 @@ namespace ClassicalSharp.Model {
protected Game game;
protected const int quadVertices = 4;
protected const int boxVertices = 6 * quadVertices;
protected RotateOrder Rotate = RotateOrder.ZYX;
protected static RotateOrder Rotate = RotateOrder.ZYX;
internal bool initalised;
public const ushort UVMask = 0x7FFF;
@ -181,6 +181,7 @@ namespace ClassicalSharp.Model {
public ModelVertex[] vertices;
public int index, texIndex;
protected byte armX = 6, armY = 12; // these translate arm model part back to (0, 0) origin
protected int GetTexture(Entity entity) {
int pTex = UsesHumanSkin ? entity.TextureId : entity.MobTextureId;
@ -261,5 +262,45 @@ namespace ClassicalSharp.Model {
}
protected enum RotateOrder { ZYX, XZY, YZX }
public void RenderArm(Entity p) {
Vector3 pos = p.Position;
if (Bobbing) pos.Y += p.anim.bobbingModel;
SetupState(p);
game.Graphics.SetBatchFormat(VertexFormat.P3fT2fC4b);
game.Graphics.BindTexture(GetTexture(p));
Matrix4 translate;
if (game.ClassicArmModel) {
// TODO: Position's not quite right.
// Matrix4.Translate(out m, -armX / 16f + 0.2f, -armY / 16f - 0.20f, 0);
// is better, but that breaks the dig animation
Matrix4.Translate(out translate, -armX / 16f, -armY / 16f - 0.10f, 0);
} else {
Matrix4.Translate(out translate, -armX / 16f + 0.10f, -armY / 16f - 0.26f, 0);
}
Matrix4 m = TransformMatrix(p, pos);
Matrix4.Mult(out m, ref m, ref game.Graphics.View);
Matrix4.Mult(out m, ref translate, ref m);
game.Graphics.LoadMatrix(ref m);
Rotate = RotateOrder.YZX;
DrawArm(p);
Rotate = RotateOrder.ZYX;
game.Graphics.LoadMatrix(ref game.Graphics.View);
}
protected void DrawArmPart(ModelPart part) {
part.RotX = armX / 16.0f; part.RotY = (armY + armY / 2) / 16.0f;
if (game.ClassicArmModel) {
DrawRotate(0, -90 * Utils.Deg2Rad, 120 * Utils.Deg2Rad, part, false);
} else {
DrawRotate(-20 * Utils.Deg2Rad, -70 * Utils.Deg2Rad, 135 * Utils.Deg2Rad, part, false);
}
}
public virtual void DrawArm(Entity p) { }
}
}

View File

@ -104,7 +104,6 @@ namespace ClassicalSharp.Model {
Register("head", "char.png", new HeadModel(game));
Register("sit", "char.png", new SittingModel(game));
Register("sitting", "char.png", new SittingModel(game));
Register("arm", "char.png", new ArmModel(game));
Register("corpse", "char.png", new CorpseModel(game));
}

View File

@ -28,7 +28,8 @@ namespace ClassicalSharp.Model {
.RotOrigin(-5, 23, 0));
RightArm = BuildBox(MakeBoxBounds(4, 12, -1, 6, 24, 1)
.TexOrigin(40, 16)
.RotOrigin(5, 23, 0));
.RotOrigin(5, 23, 0));
armX = 5;
}
public override float NameYOffset { get { return 2.075f; } }
@ -55,6 +56,11 @@ namespace ClassicalSharp.Model {
UpdateVB();
}
public override void DrawArm(Entity p) {
DrawArmPart(RightArm);
UpdateVB();
}
ModelPart Head, Torso, LeftLeg, RightLeg, LeftArm, RightArm;
}
}

View File

@ -59,6 +59,11 @@ namespace ClassicalSharp.Model {
UpdateVB();
}
public override void DrawArm(Entity p) {
DrawArmPart(RightArm);
UpdateVB();
}
ModelPart Head, Hat, Torso, LeftLeg, RightLeg, LeftArm, RightArm;
}
}

View File

@ -68,13 +68,14 @@ namespace ClassicalSharp.Renderers {
IModel model;
if (BlockInfo.Draw[block] == DrawType.Gas) {
model = game.ModelCache.Get("arm");
model = game.LocalPlayer.Model;
held.ModelScale = new Vector3(1.0f);
model.RenderArm(held);
} else {
model = game.ModelCache.Get("block");
held.ModelScale = new Vector3(0.4f);
}
model.Render(held);
model.Render(held);
}
game.Graphics.Texturing = false;
game.Graphics.RestoreAlphaState(BlockInfo.Draw[block]);

View File

@ -86,8 +86,7 @@ Real32 Entity_GetEyeHeight(struct Entity* entity) {
return entity->Model->GetEyeY(entity) * entity->ModelScale.Y;
}
void Entity_GetTransform(struct Entity* entity, Vector3 pos, Vector3 scale) {
struct Matrix* m = &entity->Transform;
void Entity_GetTransform(struct Entity* entity, Vector3 pos, Vector3 scale, struct Matrix* m) {
*m = Matrix_Identity;
struct Matrix tmp;

View File

@ -91,7 +91,7 @@ struct Entity {
void Entity_Init(struct Entity* entity);
Vector3 Entity_GetEyePosition(struct Entity* entity);
Real32 Entity_GetEyeHeight(struct Entity* entity);
void Entity_GetTransform(struct Entity* entity, Vector3 pos, Vector3 scale);
void Entity_GetTransform(struct Entity* entity, Vector3 pos, Vector3 scale, struct Matrix* m);
void Entity_GetPickingBounds(struct Entity* entity, struct AABB* bb);
void Entity_GetBounds(struct Entity* entity, struct AABB* bb);
void Entity_SetModel(struct Entity* entity, STRING_PURE String* model);

View File

@ -30,14 +30,15 @@ static void HeldBlockRenderer_RenderModel(void) {
struct IModel* model;
if (Block_Draw[held_block] == DRAW_GAS) {
String name = String_FromConst("arm"); model = ModelCache_Get(&name);
model = LocalPlayer_Instance.Base.Model;
held_entity.ModelScale = Vector3_Create1(1.0f);
IModel_RenderArm(model, &held_entity);
} else {
String name = String_FromConst("block"); model = ModelCache_Get(&name);
held_entity.ModelScale = Vector3_Create1(0.4f);
IModel_Render(model, &held_entity);
}
IModel_Render(model, &held_entity);
Gfx_SetTexturing(false);
GfxCommon_RestoreAlphaState(Block_Draw[held_block]);
Gfx_SetDepthTest(true);

View File

@ -24,18 +24,17 @@ void ModelPart_Init(struct ModelPart* part, Int32 offset, Int32 count, Real32 ro
part->RotX = rotX; part->RotY = rotY; part->RotZ = rotZ;
}
static void IModel_GetTransform(struct Entity* entity, Vector3 pos) {
Entity_GetTransform(entity, pos, entity->ModelScale);
static void IModel_GetTransform(struct Entity* entity, Vector3 pos, struct Matrix* m) {
Entity_GetTransform(entity, pos, entity->ModelScale, m);
}
static void IModel_RecalcProperties(struct Entity* entity) { }
static void IModel_NullFunc(struct Entity* entity) { }
void IModel_Init(struct IModel* model) {
model->Bobbing = true;
model->UsesSkin = true;
model->CalcHumanAnims = false;
model->UsesHumanSkin = false;
model->SurvivalScore = 5;
model->Pushes = true;
model->Gravity = 0.08f;
@ -45,9 +44,11 @@ void IModel_Init(struct IModel* model) {
model->MaxScale = 2.0f;
model->ShadowScale = 1.0f;
model->NameScale = 1.0f;
model->armX = 6; model->armY = 12;
model->GetTransform = IModel_GetTransform;
model->RecalcProperties = IModel_RecalcProperties;
model->RecalcProperties = IModel_NullFunc;
model->DrawArm = IModel_NullFunc;
}
bool IModel_ShouldRender(struct Entity* entity) {
@ -91,7 +92,7 @@ void IModel_Render(struct IModel* model, struct Entity* entity) {
IModel_SetupState(model, entity);
Gfx_SetBatchFormat(VERTEX_FORMAT_P3FT2FC4B);
model->GetTransform(entity, pos);
model->GetTransform(entity, pos, &entity->Transform);
struct Matrix m;
Matrix_Mul(&m, &entity->Transform, &Gfx_View);
@ -206,6 +207,48 @@ void IModel_DrawRotate(Real32 angleX, Real32 angleY, Real32 angleZ, struct Model
model->index += part.Count;
}
void IModel_RenderArm(struct IModel* model, struct Entity* entity) {
Vector3 pos = entity->Position;
if (model->Bobbing) pos.Y += entity->Anim.BobbingModel;
IModel_SetupState(model, entity);
Gfx_SetBatchFormat(VERTEX_FORMAT_P3FT2FC4B);
Gfx_BindTexture(IModel_GetTexture(entity));
struct Matrix translate;
if (Game_ClassicArmModel) {
// TODO: Position's not quite right.
// Matrix4.Translate(out m, -armX / 16f + 0.2f, -armY / 16f - 0.20f, 0);
// is better, but that breaks the dig animation
Matrix_Translate(&translate, -model->armX / 16.0f, -model->armY / 16.0f - 0.10f, 0);
} else {
Matrix_Translate(&translate, -model->armX / 16.0f + 0.10f, -model->armY / 16.0f - 0.26f, 0);
}
struct Matrix m; model->GetTransform(entity, pos, &m);
Matrix_Mul(&m, &m, &Gfx_View);
Matrix_Mul(&m, &translate, &m);
Gfx_LoadMatrix(&m);
IModel_Rotation = ROTATE_ORDER_YZX;
model->DrawArm(entity);
IModel_Rotation = ROTATE_ORDER_ZYX;
Gfx_LoadMatrix(&Gfx_View);
}
void IModel_DrawArmPart(struct ModelPart part) {
struct IModel* model = IModel_ActiveModel;
part.RotX = model->armX / 16.0f;
part.RotY = (model->armY + model->armY / 2) / 16.0f;
if (Game_ClassicArmModel) {
IModel_DrawRotate(0, -90 * MATH_DEG2RAD, 120 * MATH_DEG2RAD, part, false);
} else {
IModel_DrawRotate(-20 * MATH_DEG2RAD, -70 * MATH_DEG2RAD, 135 * MATH_DEG2RAD, part, false);
}
}
void BoxDesc_TexOrigin(struct BoxDesc* desc, Int32 x, Int32 y) {
desc->TexX = x; desc->TexY = y;
}

View File

@ -11,10 +11,7 @@ struct AABB;
#define IMODEL_QUAD_VERTICES 4
#define IMODEL_BOX_VERTICES (FACE_COUNT * IMODEL_QUAD_VERTICES)
#define ROTATE_ORDER_ZYX 0
#define ROTATE_ORDER_XZY 1
#define ROTATE_ORDER_YZX 2
enum ROTATE_ORDER { ROTATE_ORDER_ZYX, ROTATE_ORDER_XZY, ROTATE_ORDER_YZX };
/* Describes a vertex within a model. */
struct ModelVertex { Real32 X, Y, Z; UInt16 U, V; };
@ -34,13 +31,13 @@ struct IModel {
Int32 index;
/* Index within ModelCache's textures of the default texture for this model. */
Int8 defaultTexIndex;
UInt8 armX, armY; /* these translate arm model part back to (0, 0) */
bool initalised;
/* Whether the entity should be slightly bobbed up and down when rendering.
e.g. for players when their legs are at the peak of their swing, the whole model will be moved slightly down. */
bool Bobbing;
bool UsesSkin, CalcHumanAnims, UsesHumanSkin, Pushes;
UInt8 SurvivalScore;
Real32 Gravity; Vector3 Drag, GroundFriction;
@ -49,10 +46,11 @@ struct IModel {
void (*GetPickingBounds)(struct AABB* bb);
void (*CreateParts)(void);
void (*DrawModel)(struct Entity* entity);
void (*GetTransform)(struct Entity* entity, Vector3 pos);
void (*GetTransform)(struct Entity* entity, Vector3 pos, struct Matrix* m);
/* Recalculates properties such as name Y offset, collision size.
Not used by majority of models. (BlockModel is the exception).*/
void (*RecalcProperties)(struct Entity* entity);
void (*DrawArm)(struct Entity* entity);
Real32 NameYOffset, MaxScale, ShadowScale, NameScale;
};
@ -80,6 +78,8 @@ void IModel_UpdateVB(void);
GfxResourceID IModel_GetTexture(struct Entity* entity);
void IModel_DrawPart(struct ModelPart part);
void IModel_DrawRotate(Real32 angleX, Real32 angleY, Real32 angleZ, struct ModelPart part, bool head);
void IModel_RenderArm(struct IModel* model, struct Entity* entity);
void IModel_DrawArmPart(struct ModelPart part);
/* Describes data for a box being built. */
struct BoxDesc {

View File

@ -246,7 +246,6 @@ static struct IModel* CreeperModel_GetInstance(void) {
IModel_Init(&CreeperModel);
IModel_SetPointers(CreeperModel);
CreeperModel.vertices = CreeperModel_Vertices;
CreeperModel.SurvivalScore = 200;
CreeperModel.NameYOffset = 1.7f;
return &CreeperModel;
}
@ -315,7 +314,6 @@ static struct IModel* PigModel_GetInstance(void) {
IModel_Init(&PigModel);
IModel_SetPointers(PigModel);
PigModel.vertices = PigModel_Vertices;
PigModel.SurvivalScore = 10;
PigModel.NameYOffset = 1.075f;
return &PigModel;
}
@ -429,7 +427,6 @@ static struct IModel* SheepModel_GetInstance(void) {
IModel_Init(&SheepModel);
IModel_SetPointers(SheepModel);
SheepModel.vertices = SheepModel_Vertices;
SheepModel.SurvivalScore = 10;
SheepModel.NameYOffset = 1.48125f;
String sheep_fur = String_FromConst("sheep_fur.png");
@ -497,11 +494,17 @@ static void SkeletonModel_DrawModel(struct Entity* entity) {
IModel_UpdateVB();
}
static void SkeletonModel_DrawArm(struct Entity* entity) {
IModel_DrawArmPart(Skeleton_RightArm);
IModel_UpdateVB();
}
static struct IModel* SkeletonModel_GetInstance(void) {
IModel_Init(&SkeletonModel);
IModel_SetPointers(SkeletonModel);
SkeletonModel.DrawArm = SkeletonModel_DrawArm;
SkeletonModel.armX = 5;
SkeletonModel.vertices = SkeletonModel_Vertices;
SkeletonModel.SurvivalScore = 120;
SkeletonModel.NameYOffset = 2.075f;
return &SkeletonModel;
}
@ -580,7 +583,6 @@ static struct IModel* SpiderModel_GetInstance(void) {
IModel_Init(&SpiderModel);
IModel_SetPointers(SpiderModel);
SpiderModel.vertices = SpiderModel_Vertices;
SpiderModel.SurvivalScore = 105;
SpiderModel.NameYOffset = 1.0125f;
return &SpiderModel;
}
@ -652,11 +654,16 @@ static void ZombieModel_DrawModel(struct Entity* entity) {
IModel_UpdateVB();
}
static void ZombieModel_DrawArm(struct Entity* entity) {
IModel_DrawArmPart(Zombie_RightArm);
IModel_UpdateVB();
}
static struct IModel* ZombieModel_GetInstance(void) {
IModel_Init(&ZombieModel);
IModel_SetPointers(ZombieModel);
ZombieModel.DrawArm = ZombieModel_DrawArm;
ZombieModel.vertices = ZombieModel_Vertices;
ZombieModel.SurvivalScore = 80;
ZombieModel.NameYOffset = 2.075f;
return &ZombieModel;
}
@ -761,7 +768,6 @@ static void HumanModel_SetupState(struct Entity* entity) {
}
static void HumanModel_DrawModel(struct Entity* entity, struct ModelSet* model) {
UInt8 skinType = entity->SkinType;
IModel_DrawRotate(-entity->HeadX * MATH_DEG2RAD, 0, 0, model->Head, true);
IModel_DrawPart(model->Torso);
IModel_DrawRotate(entity->Anim.LeftLegX, 0, entity->Anim.LeftLegZ, model->LeftLeg, false);
@ -775,7 +781,7 @@ static void HumanModel_DrawModel(struct Entity* entity, struct ModelSet* model)
Gfx_SetAlphaTest(true);
IModel_ActiveModel->index = 0;
if (skinType != SKIN_TYPE_64x32) {
if (entity->SkinType != SKIN_TYPE_64x32) {
IModel_DrawPart(model->TorsoLayer);
IModel_DrawRotate(entity->Anim.LeftLegX, 0, entity->Anim.LeftLegZ, model->LeftLegLayer, false);
IModel_DrawRotate(entity->Anim.RightLegX, 0, entity->Anim.RightLegZ, model->RightLegLayer, false);
@ -789,6 +795,14 @@ static void HumanModel_DrawModel(struct Entity* entity, struct ModelSet* model)
IModel_UpdateVB();
}
static void HumanModel_DrawArm(struct Entity* entity, struct ModelSet* model) {
IModel_DrawArmPart(model->RightArm);
if (entity->SkinType != SKIN_TYPE_64x32) {
IModel_DrawArmPart(model->RightArmLayer);
}
IModel_UpdateVB();
}
struct ModelSet Humanoid_Set, Humanoid_Set64, Humanoid_SetSlim;
struct ModelVertex HumanoidModel_Vertices[IMODEL_BOX_VERTICES * (7 + 7 + 4)];
@ -834,9 +848,18 @@ static void HumanoidModel_DrawModel(struct Entity* entity) {
HumanModel_DrawModel(entity, model);
}
static void HumanoidModel_DrawArm(struct Entity* entity) {
UInt8 skinType = entity->SkinType;
struct ModelSet* model =
skinType == SKIN_TYPE_64x64_SLIM ? &Humanoid_SetSlim :
(skinType == SKIN_TYPE_64x64 ? &Humanoid_Set64 : &Humanoid_Set);
HumanModel_DrawArm(entity, model);
}
static struct IModel* HumanoidModel_GetInstance(void) {
IModel_Init(&HumanoidModel);
IModel_SetPointers(HumanoidModel);
HumanoidModel.DrawArm = HumanoidModel_DrawArm;
HumanoidModel.vertices = HumanoidModel_Vertices;
HumanoidModel.CalcHumanAnims = true;
HumanoidModel.UsesHumanSkin = true;
@ -886,9 +909,19 @@ static void ChibiModel_DrawModel(struct Entity* entity) {
HumanModel_DrawModel(entity, model);
}
static void ChibiModel_DrawArm(struct Entity* entity) {
UInt8 skinType = entity->SkinType;
struct ModelSet* model =
skinType == SKIN_TYPE_64x64_SLIM ? &Chibi_SetSlim :
(skinType == SKIN_TYPE_64x64 ? &Chibi_Set64 : &Chibi_Set);
HumanModel_DrawArm(entity, model);
}
static struct IModel* ChibiModel_GetInstance(void) {
IModel_Init(&ChibiModel);
IModel_SetPointers(ChibiModel);
ChibiModel.DrawArm = ChibiModel_DrawArm;
ChibiModel.armX = 3; ChibiModel.armY = 6;
ChibiModel.vertices = ChibiModel_Vertices;
ChibiModel.CalcHumanAnims = true;
ChibiModel.UsesHumanSkin = true;
@ -911,21 +944,22 @@ static void SittingModel_GetPickingBounds(struct AABB* bb) {
8.0f / 16.0f, (32.0f - SIT_OFFSET) / 16.0f, 4.0f / 16.0f);
}
static void SittingModel_GetTransform(struct Entity* entity, Vector3 pos) {
static void SittingModel_GetTransform(struct Entity* entity, Vector3 pos, struct Matrix* m) {
pos.Y -= (SIT_OFFSET / 16.0f) * entity->ModelScale.Y;
Entity_GetTransform(entity, pos, entity->ModelScale);
Entity_GetTransform(entity, pos, entity->ModelScale, m);
}
static void SittingModel_DrawModel(struct Entity* entity) {
entity->Anim.LeftLegX = 1.5f; entity->Anim.RightLegX = 1.5f;
entity->Anim.LeftLegZ = -0.1f; entity->Anim.RightLegZ = 0.1f;
IModel_SetupState(&HumanoidModel, entity);
HumanoidModel.DrawModel(entity);
HumanoidModel_DrawModel(entity);
}
static struct IModel* SittingModel_GetInstance(void) {
IModel_Init(&SittingModel);
IModel_SetPointers(SittingModel);
SittingModel.DrawArm = HumanoidModel_DrawArm;
SittingModel.vertices = HumanoidModel_Vertices;
SittingModel.CalcHumanAnims = true;
SittingModel.UsesHumanSkin = true;
@ -967,9 +1001,9 @@ static void HeadModel_GetPickingBounds(struct AABB* bb) {
4.0f / 16.0f, 8.0f / 16.0f, 4.0f / 16.0f);
}
static void HeadModel_GetTransform(struct Entity* entity, Vector3 pos) {
static void HeadModel_GetTransform(struct Entity* entity, Vector3 pos, struct Matrix* m) {
pos.Y -= (24.0f / 16.0f) * entity->ModelScale.Y;
Entity_GetTransform(entity, pos, entity->ModelScale);
Entity_GetTransform(entity, pos, entity->ModelScale, m);
}
static void HeadModel_DrawModel(struct Entity* entity) {
@ -999,81 +1033,6 @@ static struct IModel* HeadModel_GetInstance(void) {
}
struct IModel ArmModel;
bool arm_classic;
struct Matrix arm_translate;
static void ArmModel_SetTranslationMatrix(void) {
if (Game_ClassicArmModel) {
/* TODO: Position's not quite right.
Matrix_Translate(&arm_translate, -6.0f / 16.0f + 0.2f, -12.0f / 16.0f - 0.20f, 0.0f);
is better, but that breaks the dig animation */
Matrix_Translate(&arm_translate, -6.0f / 16.0f, -12.0f / 16.0f - 0.10f, 0.0f);
} else {
Matrix_Translate(&arm_translate, -6.0f / 16.0f + 0.10f, -12 / 16.0f - 0.26f, 0.0f);
}
}
static void ArmModel_CreateParts(void) {
arm_classic = Game_ClassicArmModel;
ArmModel_SetTranslationMatrix();
}
static Real32 ArmModel_GetEyeY(struct Entity* entity) { return 0.5f; }
static void ArmModel_GetCollisionSize(Vector3* size) { MODEL_RET_SIZE(16.0f, 16.0f, 16.0f); }
static void ArmModel_GetPickingBounds(struct AABB* bb) { AABB_FromCoords6(bb, -0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f); }
static void ArmModel_DrawPart(struct ModelPart part) {
part.RotX += 1.0f / 16.0f; part.RotY -= 4.0f / 16.0f;
if (Game_ClassicArmModel) {
IModel_DrawRotate(0, -90 * MATH_DEG2RAD, 120 * MATH_DEG2RAD, part, false);
} else {
IModel_DrawRotate(-20 * MATH_DEG2RAD, -70 * MATH_DEG2RAD, 135 * MATH_DEG2RAD, part, false);
}
}
static void ArmModel_DrawModel(struct Entity* entity) {
HumanModel_SetupState(entity);
/* If user changes option while game is running */
if (arm_classic != Game_ClassicArmModel) { ArmModel_CreateParts(); }
struct Matrix m;
Matrix_Mul(&m, &entity->Transform, &Gfx_View);
Matrix_Mul(&m, &arm_translate, &m);
Gfx_LoadMatrix(&m);
UInt8 skinType = entity->SkinType;
struct ModelSet* model =
skinType == SKIN_TYPE_64x64_SLIM ? &Humanoid_SetSlim :
(skinType == SKIN_TYPE_64x64 ? &Humanoid_Set64 : &Humanoid_Set);
IModel_Rotation = ROTATE_ORDER_YZX;
ArmModel_DrawPart(model->RightArm);
IModel_UpdateVB();
if (skinType != SKIN_TYPE_64x32) {
ArmModel.index = 0;
Gfx_SetAlphaTest(true);
ArmModel_DrawPart(model->RightArmLayer);
IModel_UpdateVB();
Gfx_SetAlphaTest(false);
}
IModel_Rotation = ROTATE_ORDER_ZYX;
}
static struct IModel* ArmModel_GetInstance(void) {
IModel_Init(&ArmModel);
IModel_SetPointers(ArmModel);
ArmModel.vertices = HumanoidModel_Vertices;
ArmModel.CalcHumanAnims = true;
ArmModel.UsesHumanSkin = true;
ArmModel.Pushes = false;
ArmModel.NameYOffset = 0.5f;
return &ArmModel;
}
struct IModel BlockModel;
BlockID BlockModel_block = BLOCK_AIR;
Vector3 BlockModel_minBB, BlockModel_maxBB;
@ -1295,7 +1254,6 @@ static void ModelCache_RegisterDefaultModels(void) {
ModelCache_Register("head", "char.png", HeadModel_GetInstance());
ModelCache_Register("sit", "char.png", SittingModel_GetInstance());
ModelCache_Register("sitting", "char.png", &SittingModel);
ModelCache_Register("arm", "char.png", ArmModel_GetInstance());
ModelCache_Register("corpse", "char.png", CorpseModel_GetInstance());
}