From eff4f46c111a03951826203a76d2d1ff5f3238f8 Mon Sep 17 00:00:00 2001 From: thedaneeffect Date: Sun, 4 Sep 2022 15:44:48 -0600 Subject: [PATCH] SeqFrame->SeqTransform, corrected names from *FrameID to transformID --- src/main/java/Component.java | 16 ++-- src/main/java/Game.java | 94 +++++++++---------- src/main/java/LocEntity.java | 6 +- src/main/java/LocType.java | 16 ++-- src/main/java/Model.java | 80 ++++++++-------- src/main/java/NPCEntity.java | 27 +++--- src/main/java/NPCType.java | 14 +-- src/main/java/PathingEntity.java | 16 ++-- src/main/java/PlayerEntity.java | 44 ++++----- src/main/java/ProjectileEntity.java | 10 +- src/main/java/SeqSkeleton.java | 4 +- .../java/{SeqFrame.java => SeqTransform.java} | 60 ++++++------ src/main/java/SeqType.java | 54 ++++++----- src/main/java/SpotAnimEntity.java | 6 +- 14 files changed, 226 insertions(+), 221 deletions(-) rename src/main/java/{SeqFrame.java => SeqTransform.java} (68%) diff --git a/src/main/java/Component.java b/src/main/java/Component.java index f45a838..fe15691 100644 --- a/src/main/java/Component.java +++ b/src/main/java/Component.java @@ -364,7 +364,7 @@ public class Component { return model; } - public Model getModel(int seqFrameId1, int seqFrameId0, boolean active) { + public Model getModel(int secondaryTransformID, int primaryTransformID, boolean active) { Model model; if (active) { @@ -377,22 +377,22 @@ public class Component { return null; } - if ((seqFrameId0 == -1) && (seqFrameId1 == -1) && (model.faceColor == null)) { + if ((primaryTransformID == -1) && (secondaryTransformID == -1) && (model.faceColor == null)) { return model; } - Model animatedModel = new Model(true, SeqFrame.isNull(seqFrameId0) & SeqFrame.isNull(seqFrameId1), false, model); + Model animatedModel = new Model(true, SeqTransform.isNull(primaryTransformID) & SeqTransform.isNull(secondaryTransformID), false, model); - if ((seqFrameId0 != -1) || (seqFrameId1 != -1)) { + if ((primaryTransformID != -1) || (secondaryTransformID != -1)) { animatedModel.createLabelReferences(); } - if (seqFrameId0 != -1) { - animatedModel.applySequenceFrame(seqFrameId0); + if (primaryTransformID != -1) { + animatedModel.applyTransform(primaryTransformID); } - if (seqFrameId1 != -1) { - animatedModel.applySequenceFrame(seqFrameId1); + if (secondaryTransformID != -1) { + animatedModel.applyTransform(secondaryTransformID); } animatedModel.calculateNormals(64, 768, -50, -10, -50, true); diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 0872387..18f088a 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -672,7 +672,7 @@ public class Game extends GameShell { ondemand = new OnDemand(); ondemand.load(archiveVersionlist, this); - SeqFrame.init(ondemand.getSeqFrameCount()); + SeqTransform.init(ondemand.getSeqFrameCount()); Model.init(ondemand.getFileCount(0), ondemand); if (!lowmem) { @@ -1168,7 +1168,7 @@ public class Game extends GameShell { Draw3D.unload(); Scene.unload(); Model.unload(); - SeqFrame.unload(); + SeqTransform.unload(); System.gc(); } @@ -3021,7 +3021,7 @@ public class Game extends GameShell { continue; } - player.lowmem = ((lowmem && (playerCount > 50)) || (playerCount > 200)) && !local && (player.seqId2 == player.seqStand); + player.lowmem = ((lowmem && (playerCount > 50)) || (playerCount > 200)) && !local && (player.secondarySeqID == player.seqStand); int stx = player.x >> 7; int stz = player.z >> 7; @@ -3590,7 +3590,7 @@ public class Game extends GameShell { } if ((request.store == 1) && (request.data != null)) { - SeqFrame.unpack(request.data); + SeqTransform.unpack(request.data); } if ((request.store == 2) && (request.file == music) && (request.data != null)) { @@ -5757,7 +5757,7 @@ public class Game extends GameShell { } model.createLabelReferences(); - model.applySequenceFrame(SeqType.instances[localPlayer.seqStand].primaryFrames[0]); + model.applyTransform(SeqType.instances[localPlayer.seqStand].transformIndices[0]); model.calculateNormals(64, 850, -30, -50, -30, true); component.modelCategory = 5; @@ -6706,10 +6706,10 @@ public class Game extends GameShell { i1 = -1; } int i2 = buffer.get1U(); - if ((i1 == npc.seqId1) && (i1 != -1)) { + if ((i1 == npc.primarySeqID) && (i1 != -1)) { int l2 = SeqType.instances[i1].anInt365; if (l2 == 1) { - npc.seqFrame1 = 0; + npc.primarySeqFrame = 0; npc.anInt1528 = 0; npc.anInt1529 = i2; npc.anInt1530 = 0; @@ -6717,9 +6717,9 @@ public class Game extends GameShell { if (l2 == 2) { npc.anInt1530 = 0; } - } else if ((i1 == -1) || (npc.seqId1 == -1) || (SeqType.instances[i1].priority >= SeqType.instances[npc.seqId1].priority)) { - npc.seqId1 = i1; - npc.seqFrame1 = 0; + } else if ((i1 == -1) || (npc.primarySeqID == -1) || (SeqType.instances[i1].priority >= SeqType.instances[npc.primarySeqID].priority)) { + npc.primarySeqID = i1; + npc.primarySeqFrame = 0; npc.anInt1528 = 0; npc.anInt1529 = i2; npc.anInt1530 = 0; @@ -7191,7 +7191,7 @@ public class Game extends GameShell { public void method96(PathingEntity entity) { if ((entity.x < 128) || (entity.z < 128) || (entity.x >= 13184) || (entity.z >= 13184)) { - entity.seqId1 = -1; + entity.primarySeqID = -1; entity.spotanim = -1; entity.forceMoveEndCycle = 0; entity.forceMoveStartCycle = 0; @@ -7200,7 +7200,7 @@ public class Game extends GameShell { entity.method446(); } if ((entity == localPlayer) && ((entity.x < 1536) || (entity.z < 1536) || (entity.x >= 11776) || (entity.z >= 11776))) { - entity.seqId1 = -1; + entity.primarySeqID = -1; entity.spotanim = -1; entity.forceMoveEndCycle = 0; entity.forceMoveStartCycle = 0; @@ -7244,7 +7244,7 @@ public class Game extends GameShell { } public void method98(PathingEntity entity) { - if ((entity.forceMoveStartCycle == loopCycle) || (entity.seqId1 == -1) || (entity.anInt1529 != 0) || ((entity.anInt1528 + 1) > SeqType.instances[entity.seqId1].getFrameDelay(entity.seqFrame1))) { + if ((entity.forceMoveStartCycle == loopCycle) || (entity.primarySeqID == -1) || (entity.anInt1529 != 0) || ((entity.anInt1528 + 1) > SeqType.instances[entity.primarySeqID].getFrameDelay(entity.primarySeqFrame))) { int duration = entity.forceMoveStartCycle - entity.forceMoveEndCycle; int delta = loopCycle - entity.forceMoveEndCycle; int dx0 = (entity.forceMoveStartSceneTileX * 128) + (entity.size * 64); @@ -7273,15 +7273,15 @@ public class Game extends GameShell { } public void method99(PathingEntity entity) { - entity.seqId2 = entity.seqStand; + entity.secondarySeqID = entity.seqStand; if (entity.pathRemaining == 0) { entity.anInt1503 = 0; return; } - if ((entity.seqId1 != -1) && (entity.anInt1529 == 0)) { - SeqType type = SeqType.instances[entity.seqId1]; + if ((entity.primarySeqID != -1) && (entity.anInt1529 == 0)) { + SeqType type = SeqType.instances[entity.primarySeqID]; if ((entity.anInt1542 > 0) && (type.anInt363 == 0)) { entity.anInt1503++; @@ -7355,7 +7355,7 @@ public class Game extends GameShell { seq = entity.seqWalk; } - entity.seqId2 = seq; + entity.secondarySeqID = seq; int moveSpeed = 4; @@ -7380,8 +7380,8 @@ public class Game extends GameShell { moveSpeed <<= 1; } - if ((moveSpeed >= 8) && (entity.seqId2 == entity.seqWalk) && (entity.seqRun != -1)) { - entity.seqId2 = entity.seqRun; + if ((moveSpeed >= 8) && (entity.secondarySeqID == entity.seqWalk) && (entity.seqRun != -1)) { + entity.secondarySeqID = entity.seqRun; } if (x < dstX) { @@ -7475,13 +7475,13 @@ public class Game extends GameShell { e.yaw &= 0x7ff; - if ((e.seqId2 == e.seqStand) && (e.yaw != e.dstYaw)) { + if ((e.secondarySeqID == e.seqStand) && (e.yaw != e.dstYaw)) { if (e.seqTurn != -1) { - e.seqId2 = e.seqTurn; + e.secondarySeqID = e.seqTurn; return; } - e.seqId2 = e.seqWalk; + e.secondarySeqID = e.seqWalk; } } } @@ -7489,18 +7489,18 @@ public class Game extends GameShell { public void method101(PathingEntity e) { e.aBoolean1541 = false; - if (e.seqId2 != -1) { - SeqType seq = SeqType.instances[e.seqId2]; + if (e.secondarySeqID != -1) { + SeqType seq = SeqType.instances[e.secondarySeqID]; e.seqCycle++; - if ((e.seqFrame2 < seq.frameCount) && (e.seqCycle > seq.getFrameDelay(e.seqFrame2))) { + if ((e.secondarySeqFrame < seq.frameCount) && (e.seqCycle > seq.getFrameDelay(e.secondarySeqFrame))) { e.seqCycle = 0; - e.seqFrame2++; + e.secondarySeqFrame++; } - if (e.seqFrame2 >= seq.frameCount) { + if (e.secondarySeqFrame >= seq.frameCount) { e.seqCycle = 0; - e.seqFrame2 = 0; + e.secondarySeqFrame = 0; } } @@ -7520,8 +7520,8 @@ public class Game extends GameShell { } } - if ((e.seqId1 != -1) && (e.anInt1529 <= 1)) { - SeqType seq = SeqType.instances[e.seqId1]; + if ((e.primarySeqID != -1) && (e.anInt1529 <= 1)) { + SeqType seq = SeqType.instances[e.primarySeqID]; if ((seq.anInt363 == 1) && (e.anInt1542 > 0) && (e.forceMoveEndCycle <= loopCycle) && (e.forceMoveStartCycle < loopCycle)) { e.anInt1529 = 1; @@ -7529,22 +7529,22 @@ public class Game extends GameShell { } } - if ((e.seqId1 != -1) && (e.anInt1529 == 0)) { - SeqType seq = SeqType.instances[e.seqId1]; + if ((e.primarySeqID != -1) && (e.anInt1529 == 0)) { + SeqType seq = SeqType.instances[e.primarySeqID]; - for (e.anInt1528++; (e.seqFrame1 < seq.frameCount) && (e.anInt1528 > seq.getFrameDelay(e.seqFrame1)); e.seqFrame1++) { - e.anInt1528 -= seq.getFrameDelay(e.seqFrame1); + for (e.anInt1528++; (e.primarySeqFrame < seq.frameCount) && (e.anInt1528 > seq.getFrameDelay(e.primarySeqFrame)); e.primarySeqFrame++) { + e.anInt1528 -= seq.getFrameDelay(e.primarySeqFrame); } - if (e.seqFrame1 >= seq.frameCount) { - e.seqFrame1 -= seq.speed; + if (e.primarySeqFrame >= seq.frameCount) { + e.primarySeqFrame -= seq.speed; e.anInt1530++; if (e.anInt1530 >= seq.anInt362) { - e.seqId1 = -1; + e.primarySeqID = -1; } - if ((e.seqFrame1 < 0) || (e.seqFrame1 >= seq.frameCount)) { - e.seqId1 = -1; + if ((e.primarySeqFrame < 0) || (e.primarySeqFrame >= seq.frameCount)) { + e.primarySeqID = -1; } } e.aBoolean1541 = seq.aBoolean358; @@ -8145,7 +8145,7 @@ public class Game extends GameShell { model = child.getModel(-1, -1, active); } else { SeqType type = SeqType.instances[seqId]; - model = child.getModel(type.secondaryFrames[child.seqFrame], type.primaryFrames[child.seqFrame], active); + model = child.getModel(type.auxiliaryTransformIndices[child.seqFrame], type.transformIndices[child.seqFrame], active); } if (model != null) { @@ -8246,10 +8246,10 @@ public class Game extends GameShell { seqId = -1; } int i2 = buffer.get1UC(); - if ((seqId == player.seqId1) && (seqId != -1)) { + if ((seqId == player.primarySeqID) && (seqId != -1)) { int i3 = SeqType.instances[seqId].anInt365; if (i3 == 1) { - player.seqFrame1 = 0; + player.primarySeqFrame = 0; player.anInt1528 = 0; player.anInt1529 = i2; player.anInt1530 = 0; @@ -8257,9 +8257,9 @@ public class Game extends GameShell { if (i3 == 2) { player.anInt1530 = 0; } - } else if ((seqId == -1) || (player.seqId1 == -1) || (SeqType.instances[seqId].priority >= SeqType.instances[player.seqId1].priority)) { - player.seqId1 = seqId; - player.seqFrame1 = 0; + } else if ((seqId == -1) || (player.primarySeqID == -1) || (SeqType.instances[seqId].priority >= SeqType.instances[player.primarySeqID].priority)) { + player.primarySeqID = seqId; + player.primarySeqFrame = 0; player.anInt1528 = 0; player.anInt1529 = i2; player.anInt1530 = 0; @@ -10823,12 +10823,12 @@ public class Game extends GameShell { if (ptype == 1) { for (PlayerEntity player : players) { if (player != null) { - player.seqId1 = -1; + player.primarySeqID = -1; } } for (NPCEntity npc : npcs) { if (npc != null) { - npc.seqId1 = -1; + npc.primarySeqID = -1; } } ptype = -1; diff --git a/src/main/java/LocEntity.java b/src/main/java/LocEntity.java index 87ed4de..ecf7359 100644 --- a/src/main/java/LocEntity.java +++ b/src/main/java/LocEntity.java @@ -46,7 +46,7 @@ public class LocEntity extends Entity { @Override public Model getModel() { - int frame = -1; + int transformID = -1; if (seq != null) { int delta = Game.loopCycle - seqCycle; @@ -75,7 +75,7 @@ public class LocEntity extends Entity { seqCycle = Game.loopCycle - delta; if (seq != null) { - frame = seq.primaryFrames[seqFrame]; + transformID = seq.transformIndices[seqFrame]; } } @@ -90,7 +90,7 @@ public class LocEntity extends Entity { if (type == null) { return null; } else { - return type.getModel(kind, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, frame); + return type.getModel(kind, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, transformID); } } diff --git a/src/main/java/LocType.java b/src/main/java/LocType.java index 52f34c0..a7bec5b 100644 --- a/src/main/java/LocType.java +++ b/src/main/java/LocType.java @@ -184,8 +184,8 @@ public class LocType { return true; } - public Model getModel(int kind, int rotation, int heightmapSW, int heightmapSE, int heightmapNE, int heightmapNW, int seqFrame) { - Model model = getModel(kind, seqFrame, rotation); + public Model getModel(int kind, int rotation, int heightmapSW, int heightmapSE, int heightmapNE, int heightmapNW, int transformID) { + Model model = getModel(kind, transformID, rotation); if (model == null) { return null; @@ -242,7 +242,7 @@ public class LocType { } } - public Model getModel(int kind, int frame, int rotation) { + public Model getModel(int kind, int transformID, int rotation) { Model model = null; long bitset; @@ -251,7 +251,7 @@ public class LocType { return null; } - bitset = ((long) index << 6) + rotation + ((long) (frame + 1) << 32); + bitset = ((long) index << 6) + rotation + ((long) (transformID + 1) << 32); Model cached = dynamicCache.get(bitset); if (cached != null) { @@ -307,7 +307,7 @@ public class LocType { return null; } - bitset = ((long) this.index << 6) + ((long) kindIndex << 3) + rotation + ((long) (frame + 1) << 32); + bitset = ((long) this.index << 6) + ((long) kindIndex << 3) + rotation + ((long) (transformID + 1) << 32); Model cached = dynamicCache.get(bitset); @@ -342,11 +342,11 @@ public class LocType { boolean scaled = (scaleX != 128) || (scaleZ != 128) || (scaleY != 128); boolean translated = (translateX != 0) || (translateY != 0) || (translateZ != 0); - Model modified = new Model(srcColor == null, SeqFrame.isNull(frame), (rotation == 0) && (frame == -1) && !scaled && !translated, model); + Model modified = new Model(srcColor == null, SeqTransform.isNull(transformID), (rotation == 0) && (transformID == -1) && !scaled && !translated, model); - if (frame != -1) { + if (transformID != -1) { modified.createLabelReferences(); - modified.applySequenceFrame(frame); + modified.applyTransform(transformID); modified.labelFaces = null; modified.labelVertices = null; } diff --git a/src/main/java/Model.java b/src/main/java/Model.java index f43bdff..f98fec5 100644 --- a/src/main/java/Model.java +++ b/src/main/java/Model.java @@ -519,7 +519,7 @@ public class Model extends Entity { /** * Constructs a new model by merging the provided models. This constructor is used to combine models before - * {@link SeqFrame}'s have been applied. Using this constructor implies all models merged are compatible with any + * {@link SeqTransform}'s have been applied. Using this constructor implies all models merged are compatible with any * animations played on them. * * @param count the model count. @@ -662,7 +662,7 @@ public class Model extends Entity { /** * Constructs a new model by combining models. This constructor is commonly used to combine models which have already - * had a {@link SeqFrame} applied, and does not copy label information. + * had a {@link SeqTransform} applied, and does not copy label information. * * @param count the model count. * @param dummy dummy. @@ -817,7 +817,7 @@ public class Model extends Entity { /** * Constructs a new model that can either share or clone the provided models attributes. This constructor is used to - * save memory by avoiding allocations, and is meant to be used with models prior to having a {@link SeqFrame} applied. + * save memory by avoiding allocations, and is meant to be used with models prior to having a {@link SeqTransform} applied. * * @param shareColors true to reference the provided model's colors. * @param shareAlpha true to reference the provided model's face alpha. @@ -975,7 +975,7 @@ public class Model extends Entity { /** * Sets this model to the provided model using a vertex pool. *

- * Face alpha may be optionally copied in case an applied {@link SeqFrame} modifies the alpha of the model. + * Face alpha may be optionally copied in case an applied {@link SeqTransform} modifies the alpha of the model. * * @param model the model. * @param shareAlpha whether to copy or share a reference to face alphas. @@ -1169,8 +1169,8 @@ public class Model extends Entity { * This method is required for applying animations to a model and should only be called once on a single instance * of a {@link Model}. * - * @see #applySequenceFrame(int) - * @see #applySequenceFrames(int, int, int[]) + * @see #applyTransform(int) + * @see #applyTransforms(int, int, int[]) * @see #applyTransform(int, int[], int, int, int) */ public void createLabelReferences() { @@ -1229,62 +1229,62 @@ public class Model extends Entity { } /** - * Applies a {@link SeqFrame} of the specified id. + * Applies a {@link SeqTransform} of the specified id. * - * @param frameId the frame id. + * @param id the transform id. */ - public void applySequenceFrame(int frameId) { + public void applyTransform(int id) { if (labelVertices == null) { return; } - if (frameId == -1) { + if (id == -1) { return; } - SeqFrame frame = SeqFrame.get(frameId); - if (frame == null) { + SeqTransform transform = SeqTransform.get(id); + if (transform == null) { return; } - SeqSkeleton skeleton = frame.skeleton; + SeqSkeleton skeleton = transform.skeleton; baseX = 0; baseY = 0; baseZ = 0; - for (int i = 0; i < frame.length; i++) { - int base = frame.bases[i]; - applyTransform(skeleton.baseTypes[base], skeleton.baseLabels[base], frame.x[i], frame.y[i], frame.z[i]); + for (int i = 0; i < transform.length; i++) { + int base = transform.bases[i]; + applyTransform(skeleton.baseTypes[base], skeleton.baseLabels[base], transform.x[i], transform.y[i], transform.z[i]); } } /** - * Applies the specified {@link SeqFrame} ids. + * Applies the specified {@link SeqTransform} ids. * - * @param frameId1 the primary frame id. - * @param frameId2 the secondary frame id. - * @param mask the mask contains base ids to prevent the primary frame from using the same bases as the secondary frame. + * @param primaryID the primary transform id. + * @param secondaryID the secondary transform id. + * @param mask the mask contains base ids to prevent the primary transform from using the same bases as the secondary transform. */ - public void applySequenceFrames(int frameId1, int frameId2, int[] mask) { - if (frameId1 == -1) { + public void applyTransforms(int primaryID, int secondaryID, int[] mask) { + if (primaryID == -1) { return; } - if ((mask == null) || (frameId2 == -1)) { - applySequenceFrame(frameId1); + if ((mask == null) || (secondaryID == -1)) { + applyTransform(primaryID); return; } - SeqFrame frame0 = SeqFrame.get(frameId1); + SeqTransform primary = SeqTransform.get(primaryID); - if (frame0 == null) { + if (primary == null) { return; } - SeqFrame frame1 = SeqFrame.get(frameId2); + SeqTransform secondary = SeqTransform.get(secondaryID); - if (frame1 == null) { - applySequenceFrame(frameId1); + if (secondary == null) { + applyTransform(primaryID); return; } - SeqSkeleton skeleton = frame0.skeleton; + SeqSkeleton skeleton = primary.skeleton; baseX = 0; baseY = 0; @@ -1293,15 +1293,15 @@ public class Model extends Entity { int counter = 0; int maskBase = mask[counter++]; - for (int i = 0; i < frame0.length; i++) { - int base = frame0.bases[i]; + for (int i = 0; i < primary.length; i++) { + int base = primary.bases[i]; while (base > maskBase) { maskBase = mask[counter++]; } if ((base != maskBase) || (skeleton.baseTypes[base] == 0)) { - applyTransform(skeleton.baseTypes[base], skeleton.baseLabels[base], frame0.x[i], frame0.y[i], frame0.z[i]); + applyTransform(skeleton.baseTypes[base], skeleton.baseLabels[base], primary.x[i], primary.y[i], primary.z[i]); } } @@ -1312,15 +1312,15 @@ public class Model extends Entity { counter = 0; maskBase = mask[counter++]; - for (int frame = 0; frame < frame1.length; frame++) { - int group = frame1.bases[frame]; + for (int i = 0; i < secondary.length; i++) { + int base = secondary.bases[i]; - while (group > maskBase) { + while (base > maskBase) { maskBase = mask[counter++]; } - if ((group == maskBase) || (skeleton.baseTypes[group] == 0)) { - applyTransform(skeleton.baseTypes[group], skeleton.baseLabels[group], frame1.x[frame], frame1.y[frame], frame1.z[frame]); + if ((base == maskBase) || (skeleton.baseTypes[base] == 0)) { + applyTransform(skeleton.baseTypes[base], skeleton.baseLabels[base], secondary.x[i], secondary.y[i], secondary.z[i]); } } } @@ -1334,8 +1334,8 @@ public class Model extends Entity { * @param x the param x. * @param y the param y. * @param z the param z. - * @see #applySequenceFrames(int, int, int[]) - * @see #applySequenceFrame(int) + * @see #applyTransforms(int, int, int[]) + * @see #applyTransform(int) * @see SeqSkeleton#OP_BASE * @see SeqSkeleton#OP_TRANSLATE * @see SeqSkeleton#OP_ROTATE diff --git a/src/main/java/NPCEntity.java b/src/main/java/NPCEntity.java index 42107af..b6454cc 100644 --- a/src/main/java/NPCEntity.java +++ b/src/main/java/NPCEntity.java @@ -10,21 +10,22 @@ public class NPCEntity extends PathingEntity { } public Model getSequencedModel() { - if ((super.seqId1 >= 0) && (super.anInt1529 == 0)) { - int frame1 = SeqType.instances[super.seqId1].primaryFrames[super.seqFrame1]; - int frame2 = -1; - if ((super.seqId2 >= 0) && (super.seqId2 != super.seqStand)) { - frame2 = SeqType.instances[super.seqId2].primaryFrames[super.seqFrame2]; + if ((super.primarySeqID >= 0) && (super.anInt1529 == 0)) { + int primaryTransformID = SeqType.instances[super.primarySeqID].transformIndices[super.primarySeqFrame]; + int secondaryTransformID = -1; + if ((super.secondarySeqID >= 0) && (super.secondarySeqID != super.seqStand)) { + secondaryTransformID = SeqType.instances[super.secondarySeqID].transformIndices[super.secondarySeqFrame]; } - return type.getSequencedModel(frame2, frame1, SeqType.instances[super.seqId1].anIntArray357); + return type.getSequencedModel(secondaryTransformID, primaryTransformID, SeqType.instances[super.primarySeqID].mask); } - int frame = -1; + int transformID = -1; - if (super.seqId2 >= 0) { - frame = SeqType.instances[super.seqId2].primaryFrames[super.seqFrame2]; + if (super.secondarySeqID >= 0) { + transformID = SeqType.instances[super.secondarySeqID].transformIndices[super.secondarySeqFrame]; } - return type.getSequencedModel(-1, frame, null); + + return type.getSequencedModel(-1, transformID, null); } @Override @@ -46,13 +47,13 @@ public class NPCEntity extends PathingEntity { Model model0 = spotanim.getModel(); if (model0 != null) { - int frame = spotanim.seq.primaryFrames[super.spotanimFrame]; + int transformID = spotanim.seq.transformIndices[super.spotanimFrame]; // create a copy of the model - Model model1 = new Model(true, SeqFrame.isNull(frame), false, model0); + Model model1 = new Model(true, SeqTransform.isNull(transformID), false, model0); model1.translate(0, -super.spotanimY, 0); model1.createLabelReferences(); - model1.applySequenceFrame(frame); + model1.applyTransform(transformID); model1.labelFaces = null; model1.labelVertices = null; diff --git a/src/main/java/NPCType.java b/src/main/java/NPCType.java index 4fc4c6b..273c72a 100644 --- a/src/main/java/NPCType.java +++ b/src/main/java/NPCType.java @@ -159,13 +159,13 @@ public class NPCType { } } - public Model getSequencedModel(int seqFrame2, int seqFrame1, int[] seqMask) { + public Model getSequencedModel(int secondaryTransformID, int primaryTransformID, int[] seqMask) { if (overrides != null) { NPCType override = getOverrideType(); if (override == null) { return null; } else { - return override.getSequencedModel(seqFrame2, seqFrame1, seqMask); + return override.getSequencedModel(secondaryTransformID, primaryTransformID, seqMask); } } @@ -208,12 +208,12 @@ public class NPCType { } Model model_1 = Model.EMPTY; - model_1.set(model, SeqFrame.isNull(seqFrame1) & SeqFrame.isNull(seqFrame2)); + model_1.set(model, SeqTransform.isNull(primaryTransformID) & SeqTransform.isNull(secondaryTransformID)); - if ((seqFrame1 != -1) && (seqFrame2 != -1)) { - model_1.applySequenceFrames(seqFrame1, seqFrame2, seqMask); - } else if (seqFrame1 != -1) { - model_1.applySequenceFrame(seqFrame1); + if ((primaryTransformID != -1) && (secondaryTransformID != -1)) { + model_1.applyTransforms(primaryTransformID, secondaryTransformID, seqMask); + } else if (primaryTransformID != -1) { + model_1.applyTransform(primaryTransformID); } if ((anInt91 != 128) || (anInt86 != 128)) { diff --git a/src/main/java/PathingEntity.java b/src/main/java/PathingEntity.java index 753da21..f5d60b5 100644 --- a/src/main/java/PathingEntity.java +++ b/src/main/java/PathingEntity.java @@ -20,8 +20,8 @@ public class PathingEntity extends Entity { public int seqStand = -1; public int seqTurn = -1; public int chatColor; - public int seqId2 = -1; - public int seqFrame2; + public int secondarySeqID = -1; + public int secondarySeqFrame; public int seqCycle; public int spotanim = -1; public int spotanimFrame; @@ -29,8 +29,8 @@ public class PathingEntity extends Entity { public int anInt1523; public int spotanimY; public int pathRemaining; - public int seqId1 = -1; - public int seqFrame1; + public int primarySeqID = -1; + public int primarySeqFrame; public int anInt1528; public int anInt1529; public int anInt1530; @@ -64,8 +64,8 @@ public class PathingEntity extends Entity { } public void move(int x, int z, boolean teleport) { - if ((seqId1 != -1) && (SeqType.instances[seqId1].anInt364 == 1)) { - seqId1 = -1; + if ((primarySeqID != -1) && (SeqType.instances[primarySeqID].anInt364 == 1)) { + primarySeqID = -1; } if (!teleport) { int dx = x - pathTileX[0]; @@ -144,8 +144,8 @@ public class PathingEntity extends Entity { j++; k--; } - if ((seqId1 != -1) && (SeqType.instances[seqId1].anInt364 == 1)) { - seqId1 = -1; + if ((primarySeqID != -1) && (SeqType.instances[primarySeqID].anInt364 == 1)) { + primarySeqID = -1; } if (pathRemaining < 9) { pathRemaining++; diff --git a/src/main/java/PlayerEntity.java b/src/main/java/PlayerEntity.java index 16a65c7..c9ece72 100644 --- a/src/main/java/PlayerEntity.java +++ b/src/main/java/PlayerEntity.java @@ -59,10 +59,10 @@ public class PlayerEntity extends PathingEntity { Model spotModel1 = spot.getModel(); if (spotModel1 != null) { - Model spotModel2 = new Model(true, SeqFrame.isNull(super.spotanimFrame), false, spotModel1); + Model spotModel2 = new Model(true, SeqTransform.isNull(super.spotanimFrame), false, spotModel1); spotModel2.translate(0, -super.spotanimY, 0); spotModel2.createLabelReferences(); - spotModel2.applySequenceFrame(spot.seq.primaryFrames[super.spotanimFrame]); + spotModel2.applyTransform(spot.seq.transformIndices[super.spotanimFrame]); spotModel2.labelFaces = null; spotModel2.labelVertices = null; if ((spot.scaleXY != 128) || (spot.scaleZ != 128)) { @@ -217,27 +217,27 @@ public class PlayerEntity extends PathingEntity { public Model getSequencedModel() { if (npcType != null) { - int frame = -1; - if ((super.seqId1 >= 0) && (super.anInt1529 == 0)) { - frame = SeqType.instances[super.seqId1].primaryFrames[super.seqFrame1]; - } else if (super.seqId2 >= 0) { - frame = SeqType.instances[super.seqId2].primaryFrames[super.seqFrame2]; + int transformID = -1; + if ((super.primarySeqID >= 0) && (super.anInt1529 == 0)) { + transformID = SeqType.instances[super.primarySeqID].transformIndices[super.primarySeqFrame]; + } else if (super.secondarySeqID >= 0) { + transformID = SeqType.instances[super.secondarySeqID].transformIndices[super.secondarySeqFrame]; } - return npcType.getSequencedModel(-1, frame, null); + return npcType.getSequencedModel(-1, transformID, null); } long hashCode = this.appearanceHashcode; - int frame1 = -1; - int frame2 = -1; + int primaryTransformID = -1; + int secondaryTransformID = -1; int rightHandValue = -1; int leftHandValue = -1; - if ((super.seqId1 >= 0) && (super.anInt1529 == 0)) { - SeqType type = SeqType.instances[super.seqId1]; - frame1 = type.primaryFrames[super.seqFrame1]; + if ((super.primarySeqID >= 0) && (super.anInt1529 == 0)) { + SeqType type = SeqType.instances[super.primarySeqID]; + primaryTransformID = type.transformIndices[super.primarySeqFrame]; - if ((super.seqId2 >= 0) && (super.seqId2 != super.seqStand)) { - frame2 = SeqType.instances[super.seqId2].primaryFrames[super.seqFrame2]; + if ((super.secondarySeqID >= 0) && (super.secondarySeqID != super.seqStand)) { + secondaryTransformID = SeqType.instances[super.secondarySeqID].transformIndices[super.secondarySeqFrame]; } if (type.rightHandOverride >= 0) { @@ -249,8 +249,8 @@ public class PlayerEntity extends PathingEntity { leftHandValue = type.leftHandOverride; hashCode += ((long) leftHandValue - appearances[3]) << 16; } - } else if (super.seqId2 >= 0) { - frame1 = SeqType.instances[super.seqId2].primaryFrames[super.seqFrame2]; + } else if (super.secondarySeqID >= 0) { + primaryTransformID = SeqType.instances[super.secondarySeqID].transformIndices[super.secondarySeqFrame]; } Model model = modelCache.get(hashCode); @@ -339,12 +339,12 @@ public class PlayerEntity extends PathingEntity { } Model animated = Model.EMPTY; - animated.set(model, SeqFrame.isNull(frame1) & SeqFrame.isNull(frame2)); + animated.set(model, SeqTransform.isNull(primaryTransformID) & SeqTransform.isNull(secondaryTransformID)); - if ((frame1 != -1) && (frame2 != -1)) { - animated.applySequenceFrames(frame1, frame2, SeqType.instances[super.seqId1].anIntArray357); - } else if (frame1 != -1) { - animated.applySequenceFrame(frame1); + if ((primaryTransformID != -1) && (secondaryTransformID != -1)) { + animated.applyTransforms(primaryTransformID, secondaryTransformID, SeqType.instances[super.primarySeqID].mask); + } else if (primaryTransformID != -1) { + animated.applyTransform(primaryTransformID); } animated.calculateBoundsCylinder(); diff --git a/src/main/java/ProjectileEntity.java b/src/main/java/ProjectileEntity.java index 8306158..4be6d0f 100644 --- a/src/main/java/ProjectileEntity.java +++ b/src/main/java/ProjectileEntity.java @@ -68,14 +68,14 @@ public class ProjectileEntity extends Entity { if (model == null) { return null; } - int j = -1; + int transformID = -1; if (aType_1592.seq != null) { - j = aType_1592.seq.primaryFrames[anInt1593]; + transformID = aType_1592.seq.transformIndices[anInt1593]; } - Model model_1 = new Model(true, SeqFrame.isNull(j), false, model); - if (j != -1) { + Model model_1 = new Model(true, SeqTransform.isNull(transformID), false, model); + if (transformID != -1) { model_1.createLabelReferences(); - model_1.applySequenceFrame(j); + model_1.applyTransform(transformID); model_1.labelFaces = null; model_1.labelVertices = null; } diff --git a/src/main/java/SeqSkeleton.java b/src/main/java/SeqSkeleton.java index f982045..55f5578 100644 --- a/src/main/java/SeqSkeleton.java +++ b/src/main/java/SeqSkeleton.java @@ -1,8 +1,8 @@ /** * A {@link SeqSkeleton} describes the usage and relationship between groups of vertices. * - * @see Model#applySequenceFrame(int) - * @see Model#applySequenceFrames(int, int, int[]) + * @see Model#applyTransform(int) + * @see Model#applyTransforms(int, int, int[]) */ public class SeqSkeleton { /** diff --git a/src/main/java/SeqFrame.java b/src/main/java/SeqTransform.java similarity index 68% rename from src/main/java/SeqFrame.java rename to src/main/java/SeqTransform.java index edd8128..c7fd5a2 100644 --- a/src/main/java/SeqFrame.java +++ b/src/main/java/SeqTransform.java @@ -1,12 +1,12 @@ /** - * A {@link SeqFrame} contains the {@link SeqSkeleton} and x,y,z parameters to transform a {@link Model}. + * A {@link SeqTransform} contains the {@link SeqSkeleton} and x,y,z parameters to transform a {@link Model}. * - * @see Model#applySequenceFrame(int) - * @see Model#applySequenceFrames(int, int, int[]) + * @see Model#applyTransform(int) + * @see Model#applyTransforms(int, int, int[]) */ -public class SeqFrame { +public class SeqTransform { - public static SeqFrame[] instances; + public static SeqTransform[] instances; /** * Syntax sugar. @@ -24,7 +24,7 @@ public class SeqFrame { * @param count the count */ public static void init(int count) { - instances = new SeqFrame[count + 1]; + instances = new SeqTransform[count + 1]; } /** @@ -35,12 +35,12 @@ public class SeqFrame { } /** - * Gets the {@link SeqFrame} + * Gets the {@link SeqTransform} * - * @param id the frame id. - * @return the {@link SeqFrame} or null if it does not exist. + * @param id the transform id. + * @return the {@link SeqTransform} or null if it does not exist. */ - public static SeqFrame get(int id) { + public static SeqTransform get(int id) { if ((instances == null) || (id < 0) || (id >= instances.length)) { return null; } else { @@ -49,10 +49,8 @@ public class SeqFrame { } /** - * Reads the animation data and stores its frames in {@link #instances}. - *

- * Note: This method can read multiple {@link SeqFrame} which means the input data can be an entire working - * animation. + * This method can read multiple {@link SeqTransform}s which means the input data can be all the transforms + * related to the loaded skeleton. * * @param src the animation data. * @see #get(int) @@ -91,9 +89,9 @@ public class SeqFrame { int[] z = new int[500]; for (int i = 0; i < frameCount; i++) { - SeqFrame frame = instances[header.get2U()] = new SeqFrame(); - frame.delay = del.get1U(); - frame.skeleton = skeleton; + SeqTransform transform = instances[header.get2U()] = new SeqTransform(); + transform.delay = del.get1U(); + transform.skeleton = skeleton; int baseCount = header.get1U(); int lastBase = -1; @@ -107,7 +105,7 @@ public class SeqFrame { } if (skeleton.baseTypes[base] != SeqSkeleton.OP_BASE) { - // Look for any skipped ORIGIN bases and insert them into this frame. + // Look for any skipped ORIGIN bases and insert them into this transform. for (int cur = base - 1; cur > lastBase; cur--) { if (skeleton.baseTypes[cur] == SeqSkeleton.OP_BASE) { bases[length] = cur; @@ -150,23 +148,23 @@ public class SeqFrame { length++; } - frame.length = length; - frame.bases = new int[length]; - frame.x = new int[length]; - frame.y = new int[length]; - frame.z = new int[length]; + transform.length = length; + transform.bases = new int[length]; + transform.x = new int[length]; + transform.y = new int[length]; + transform.z = new int[length]; for (int j = 0; j < length; j++) { - frame.bases[j] = bases[j]; - frame.x[j] = x[j]; - frame.y[j] = y[j]; - frame.z[j] = z[j]; + transform.bases[j] = bases[j]; + transform.x[j] = x[j]; + transform.y[j] = y[j]; + transform.z[j] = z[j]; } } } /** - * The skeleton associated to this frame. + * The skeleton associated to this transform. */ public SeqSkeleton skeleton; /** @@ -174,15 +172,15 @@ public class SeqFrame { */ public int delay; /** - * The number of operations the frame performs. + * The number of operations this transform performs. */ public int length; /** - * The list of bases the frame uses. + * The list of bases this transform uses. */ public int[] bases; /** - * The frame parameters. + * This transforms parameters. */ public int[] x, y, z; diff --git a/src/main/java/SeqType.java b/src/main/java/SeqType.java index b3aebc5..155a7cd 100644 --- a/src/main/java/SeqType.java +++ b/src/main/java/SeqType.java @@ -25,11 +25,15 @@ public class SeqType { } public int frameCount; - public int[] primaryFrames; - public int[] secondaryFrames; + public int[] transformIndices; + + /** + * Auxiliary transform indices appear to only be used by a {@link Component} of type 6 as seen in {@link Game#drawParentComponent(Component, int, int, int)}. + */ + public int[] auxiliaryTransformIndices; public int[] frameDelays; public int speed = -1; - public int[] anIntArray357; + public int[] mask; public boolean aBoolean358 = false; public int priority = 5; public int rightHandOverride = -1; @@ -45,16 +49,18 @@ public class SeqType { public int getFrameDelay(int frame) { int delay = frameDelays[frame]; - if (delay == 0) { - SeqFrame transform = SeqFrame.get(primaryFrames[frame]); + if (delay == 0) { + SeqTransform transform = SeqTransform.get(transformIndices[frame]); if (transform != null) { delay = frameDelays[frame] = transform.delay; } } + if (delay == 0) { delay = 1; } + return delay; } @@ -65,26 +71,26 @@ public class SeqType { break; } else if (op == 1) { frameCount = buffer.get1U(); - primaryFrames = new int[frameCount]; - secondaryFrames = new int[frameCount]; + transformIndices = new int[frameCount]; + auxiliaryTransformIndices = new int[frameCount]; frameDelays = new int[frameCount]; - for (int j = 0; j < frameCount; j++) { - primaryFrames[j] = buffer.get2U(); - secondaryFrames[j] = buffer.get2U(); - if (secondaryFrames[j] == 65535) { - secondaryFrames[j] = -1; + for (int f = 0; f < frameCount; f++) { + transformIndices[f] = buffer.get2U(); + auxiliaryTransformIndices[f] = buffer.get2U(); + if (auxiliaryTransformIndices[f] == 65535) { + auxiliaryTransformIndices[f] = -1; } - frameDelays[j] = buffer.get2U(); + frameDelays[f] = buffer.get2U(); } } else if (op == 2) { speed = buffer.get2U(); } else if (op == 3) { - int k = buffer.get1U(); - anIntArray357 = new int[k + 1]; - for (int l = 0; l < k; l++) { - anIntArray357[l] = buffer.get1U(); + int count = buffer.get1U(); + mask = new int[count + 1]; + for (int l = 0; l < count; l++) { + mask[l] = buffer.get1U(); } - anIntArray357[k] = 9999999; + mask[count] = 9999999; } else if (op == 4) { aBoolean358 = true; } else if (op == 5) { @@ -110,16 +116,16 @@ public class SeqType { if (frameCount == 0) { frameCount = 1; - primaryFrames = new int[1]; - primaryFrames[0] = -1; - secondaryFrames = new int[1]; - secondaryFrames[0] = -1; + transformIndices = new int[1]; + transformIndices[0] = -1; + auxiliaryTransformIndices = new int[1]; + auxiliaryTransformIndices[0] = -1; frameDelays = new int[1]; frameDelays[0] = -1; } if (anInt363 == -1) { - if (anIntArray357 != null) { + if (mask != null) { anInt363 = 2; } else { anInt363 = 0; @@ -127,7 +133,7 @@ public class SeqType { } if (anInt364 == -1) { - if (anIntArray357 != null) { + if (mask != null) { anInt364 = 2; return; } diff --git a/src/main/java/SpotAnimEntity.java b/src/main/java/SpotAnimEntity.java index c3c1255..2e18054 100644 --- a/src/main/java/SpotAnimEntity.java +++ b/src/main/java/SpotAnimEntity.java @@ -31,13 +31,13 @@ public class SpotAnimEntity extends Entity { return null; } - int frame = type.seq.primaryFrames[seqFrame]; + int transformID = type.seq.transformIndices[seqFrame]; - Model model = new Model(true, SeqFrame.isNull(frame), false, base); + Model model = new Model(true, SeqTransform.isNull(transformID), false, base); if (!seqComplete) { model.createLabelReferences(); - model.applySequenceFrame(frame); + model.applyTransform(transformID); model.labelFaces = null; model.labelVertices = null; }