Skip to content

Commit

Permalink
Fixed animation issues related to dragons membrane as well as the rot…
Browse files Browse the repository at this point in the history
…ation points for animations not being set correctly.

Resolves AlexModGuy#4180
  • Loading branch information
TheBv committed Oct 14, 2021
1 parent 7da04b2 commit 09bf862
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,113 +309,113 @@ protected void animate(TabulaModel model, T entity, float limbSwing, float limbS
//Bite
if (model.llibAnimator.setAnimation(T.ANIMATION_BITE)) {
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.BITE1));
moveToPose(model, getModel(EnumDragonPoses.BITE1));
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(5);
moveToPoseSameModel(model, getModel(EnumDragonPoses.BITE2));
moveToPose(model, getModel(EnumDragonPoses.BITE2));
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(5);
moveToPoseSameModel(model, getModel(EnumDragonPoses.BITE3));
moveToPose(model, getModel(EnumDragonPoses.BITE3));
model.llibAnimator.endKeyframe();
model.llibAnimator.resetKeyframe(10);
}
//Shakeprey
if (model.llibAnimator.setAnimation(T.ANIMATION_SHAKEPREY)) {
model.llibAnimator.startKeyframe(15);
moveToPoseSameModel(model, getModel(EnumDragonPoses.GRAB1));
moveToPose(model, getModel(EnumDragonPoses.GRAB1));
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.GRAB2));
moveToPose(model, getModel(EnumDragonPoses.GRAB2));
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.GRAB_SHAKE1));
moveToPose(model, getModel(EnumDragonPoses.GRAB_SHAKE1));
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.GRAB_SHAKE2));
moveToPose(model, getModel(EnumDragonPoses.GRAB_SHAKE2));
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.GRAB_SHAKE3));
moveToPose(model, getModel(EnumDragonPoses.GRAB_SHAKE3));
model.llibAnimator.endKeyframe();
model.llibAnimator.resetKeyframe(10);
}
//Tailwhack
if (model.llibAnimator.setAnimation(T.ANIMATION_TAILWHACK)) {
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.TAIL_WHIP1));
moveToPose(model, getModel(EnumDragonPoses.TAIL_WHIP1));
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.TAIL_WHIP2));
moveToPose(model, getModel(EnumDragonPoses.TAIL_WHIP2));
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.TAIL_WHIP3));
moveToPose(model, getModel(EnumDragonPoses.TAIL_WHIP3));
model.llibAnimator.endKeyframe();
model.llibAnimator.resetKeyframe(10);
}
//Wingblast TODO: fix membrane positioning
//Wingblast
if (model.llibAnimator.setAnimation(T.ANIMATION_WINGBLAST)) {
model.llibAnimator.startKeyframe(5);
moveToPoseSameModel(model, getModel(EnumDragonPoses.WING_BLAST3), true);
moveToPose(model, getModel(EnumDragonPoses.WING_BLAST3));
model.llibAnimator.move(modelCubeBodyUpper, 0, -4F, 0);
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(5);
moveToPoseSameModel(model, getModel(EnumDragonPoses.WING_BLAST4), true);
moveToPose(model, getModel(EnumDragonPoses.WING_BLAST4));
model.llibAnimator.move(modelCubeBodyUpper, 0, -4F, 0);
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(5);
moveToPoseSameModel(model, getModel(EnumDragonPoses.WING_BLAST3), true);
moveToPose(model, getModel(EnumDragonPoses.WING_BLAST3));
model.llibAnimator.move(modelCubeBodyUpper, 0, -4F, 0);
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(5);
moveToPoseSameModel(model, getModel(EnumDragonPoses.WING_BLAST4), true);
moveToPose(model, getModel(EnumDragonPoses.WING_BLAST4));
model.llibAnimator.move(modelCubeBodyUpper, 0, -4F, 0);
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(5);
moveToPoseSameModel(model, getModel(EnumDragonPoses.WING_BLAST5), true);
moveToPose(model, getModel(EnumDragonPoses.WING_BLAST5));
model.llibAnimator.move(modelCubeBodyUpper, 0, -4F, 0);
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(5);
moveToPoseSameModel(model, getModel(EnumDragonPoses.WING_BLAST6), true);
moveToPose(model, getModel(EnumDragonPoses.WING_BLAST6));
model.llibAnimator.move(modelCubeBodyUpper, 0, -4F, 0);
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(5);
moveToPoseSameModel(model, getModel(EnumDragonPoses.WING_BLAST7), true);
moveToPose(model, getModel(EnumDragonPoses.WING_BLAST7));
model.llibAnimator.move(modelCubeBodyUpper, 0, -4F, 0);
model.llibAnimator.endKeyframe();
model.llibAnimator.resetKeyframe(10);
}
//Roar
if (model.llibAnimator.setAnimation(T.ANIMATION_ROAR)) {
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.ROAR1));
moveToPose(model, getModel(EnumDragonPoses.ROAR1));
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.ROAR2));
moveToPose(model, getModel(EnumDragonPoses.ROAR2));
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.ROAR3));
moveToPose(model, getModel(EnumDragonPoses.ROAR3));
model.llibAnimator.endKeyframe();
model.llibAnimator.resetKeyframe(10);
}
//Epicroar
if (model.llibAnimator.setAnimation(T.ANIMATION_EPIC_ROAR)) {
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.EPIC_ROAR1));
moveToPose(model, getModel(EnumDragonPoses.EPIC_ROAR1));
model.llibAnimator.move(modelCubeBodyUpper, 0, -6.8F, 0);
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.EPIC_ROAR2));
moveToPose(model, getModel(EnumDragonPoses.EPIC_ROAR2));
model.llibAnimator.move(modelCubeBodyUpper, 0, -6.8F, 0);
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.EPIC_ROAR3));
moveToPose(model, getModel(EnumDragonPoses.EPIC_ROAR3));
model.llibAnimator.move(modelCubeBodyUpper, 0, -6.8F, 0);
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.EPIC_ROAR2));
moveToPose(model, getModel(EnumDragonPoses.EPIC_ROAR2));
model.llibAnimator.move(modelCubeBodyUpper, 0, -6.8F, 0);
model.llibAnimator.endKeyframe();
model.llibAnimator.startKeyframe(10);
moveToPoseSameModel(model, getModel(EnumDragonPoses.EPIC_ROAR3));
moveToPose(model, getModel(EnumDragonPoses.EPIC_ROAR3));
model.llibAnimator.move(modelCubeBodyUpper, 0, -6.8F, 0);
model.llibAnimator.endKeyframe();
model.llibAnimator.resetKeyframe(10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,46 +67,6 @@ public void rotate(ModelAnimator animator, AdvancedModelBox model, float x, floa
animator.rotate(model, (float) Math.toRadians(x), (float) Math.toRadians(y), (float) Math.toRadians(z));
}

public void moveToPoseSameModel(TabulaModel model, TabulaModel modelTo) {
moveToPoseSameModel(model, modelTo, false);
}

public void moveToPoseSameModel(TabulaModel model, TabulaModel modelTo, boolean membraneFlag){
Map<String, AdvancedModelBox> modelMap = model.getCubes();
Map<String, AdvancedModelBox> modelToMap = modelTo.getCubes();
Map<String, AdvancedModelBox> baseModelMap = baseModel.getCubes();
//Just in case check if the sizes are the same
if (modelMap.size() == modelToMap.size() && modelToMap.size() == baseModelMap.size()) {
Iterator<Map.Entry<String, AdvancedModelBox>> modelIter = modelMap.entrySet().iterator();
Iterator<Map.Entry<String, AdvancedModelBox>> modelToIter = modelToMap.entrySet().iterator();
Iterator<Map.Entry<String, AdvancedModelBox>> baseModelIter = baseModelMap.entrySet().iterator();
while (modelIter.hasNext()) {
AdvancedModelBox cube = modelIter.next().getValue();
AdvancedModelBox modelToCube = modelToIter.next().getValue();
AdvancedModelBox baseCube = baseModelIter.next().getValue();
if (!isRotationEqual(baseCube, modelToCube)) {
float toX = modelToCube.rotateAngleX;
float toY = modelToCube.rotateAngleY;
float toZ = modelToCube.rotateAngleZ;
if(membraneFlag && cube.boxName != null && cube.boxName.toLowerCase().contains("membrane")){
//TODO: fix membrane positioning
}else{
model.llibAnimator.rotate(cube, distance(cube.rotateAngleX, toX), distance(cube.rotateAngleY, toY), distance(cube.rotateAngleZ, toZ));
}
}
if (!isPositionEqual(baseCube, modelToCube)) {
float toX = modelToCube.rotationPointX;
float toY = modelToCube.rotationPointY;
float toZ = modelToCube.rotationPointZ;
model.llibAnimator.move(cube, distance(cube.rotationPointX, toX), distance(cube.rotationPointY, toY), distance(cube.rotationPointZ, toZ));
}
}
}
else {
//fallback function
moveToPose(model,modelTo);
}
}
public void moveToPose(TabulaModel model, TabulaModel modelTo) {
for (AdvancedModelBox cube : model.getCubes().values()) {
AdvancedModelBox cubeTo = modelTo.getCube(cube.boxName);
Expand All @@ -120,7 +80,7 @@ public void moveToPose(TabulaModel model, TabulaModel modelTo) {
float toX = cubeTo.rotationPointX;
float toY = cubeTo.rotationPointY;
float toZ = cubeTo.rotationPointZ;
model.llibAnimator.move(cube, distance(cube.rotationPointX, toX), distance(cube.rotationPointY, toY), distance(cube.rotationPointZ, toZ));
model.llibAnimator.move(cube, toX - cube.rotationPointX, toY - cube.rotationPointY, toZ - cube.rotationPointZ);
}
}
}
Expand Down

0 comments on commit 09bf862

Please sign in to comment.