mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Add swizzling for animations not authored with YZX rotations within blender (haven't updated the import/export yet)
This commit is contained in:
parent
700e02223f
commit
67eb2be5a7
@ -51,14 +51,26 @@ public class AnimationLoader {
|
|||||||
// The offsets are only required when sequences are played for an object, which is why we don't globally offset! The obj rendering handles the non-animated case fine
|
// The offsets are only required when sequences are played for an object, which is why we don't globally offset! The obj rendering handles the non-animated case fine
|
||||||
// Effectively, this removes double translation AND ensures that rotations occur around the individual object origin, rather than the weapon origin
|
// Effectively, this removes double translation AND ensures that rotations occur around the individual object origin, rather than the weapon origin
|
||||||
HashMap<String, double[]> offsets = new HashMap<String, double[]>();
|
HashMap<String, double[]> offsets = new HashMap<String, double[]>();
|
||||||
|
HashMap<String, double[]> rotModes = new HashMap<String, double[]>();
|
||||||
for(Map.Entry<String, JsonElement> root : json.getAsJsonObject("offset").entrySet()) {
|
for(Map.Entry<String, JsonElement> root : json.getAsJsonObject("offset").entrySet()) {
|
||||||
double[] offset = new double[3];
|
JsonArray array = root.getValue().getAsJsonArray();
|
||||||
|
|
||||||
|
double[] offset = new double[3];
|
||||||
for(int i = 0; i < 3; i++) {
|
for(int i = 0; i < 3; i++) {
|
||||||
offset[i] = root.getValue().getAsJsonArray().get(i).getAsDouble();
|
offset[i] = array.get(i).getAsDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
offsets.put(root.getKey(), offset);
|
offsets.put(root.getKey(), offset);
|
||||||
|
|
||||||
|
if(array.size() >= 6) {
|
||||||
|
double[] rotMode = new double[3];
|
||||||
|
for(int i = 0; i < 3; i++) {
|
||||||
|
rotMode[i] = array.get(i + 3).getAsDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
rotModes.put(root.getKey(), rotMode);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,8 +83,10 @@ public class AnimationLoader {
|
|||||||
for(Map.Entry<String, JsonElement> model : entryObject.entrySet()) {
|
for(Map.Entry<String, JsonElement> model : entryObject.entrySet()) {
|
||||||
String modelName = model.getKey();
|
String modelName = model.getKey();
|
||||||
double[] offset = new double[3];
|
double[] offset = new double[3];
|
||||||
if (offsets.containsKey(modelName)) offset = offsets.get(modelName);
|
double[] rotMode = new double[] { 0, 1, 2 };
|
||||||
animation.addBus(modelName, loadSequence(model.getValue().getAsJsonObject(), offset));
|
if(offsets.containsKey(modelName)) offset = offsets.get(modelName);
|
||||||
|
if(rotModes.containsKey(modelName)) rotMode = rotModes.get(modelName);
|
||||||
|
animation.addBus(modelName, loadSequence(model.getValue().getAsJsonObject(), offset, rotMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
animations.put(root.getKey(), animation);
|
animations.put(root.getKey(), animation);
|
||||||
@ -81,7 +95,7 @@ public class AnimationLoader {
|
|||||||
return animations;
|
return animations;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BusAnimationSequence loadSequence(JsonObject json, double[] offset) {
|
private static BusAnimationSequence loadSequence(JsonObject json, double[] offset, double[] rotMode) {
|
||||||
BusAnimationSequence sequence = new BusAnimationSequence();
|
BusAnimationSequence sequence = new BusAnimationSequence();
|
||||||
|
|
||||||
// Location fcurves
|
// Location fcurves
|
||||||
@ -130,6 +144,7 @@ public class AnimationLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sequence.offset = offset;
|
sequence.offset = offset;
|
||||||
|
sequence.rotMode = rotMode;
|
||||||
|
|
||||||
return sequence;
|
return sequence;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,9 @@ public class BusAnimationSequence {
|
|||||||
|
|
||||||
public double[] offset = new double[3];
|
public double[] offset = new double[3];
|
||||||
|
|
||||||
|
// swizzle me timbers
|
||||||
|
public double[] rotMode = new double[] { 0, 1, 2 };
|
||||||
|
|
||||||
|
|
||||||
public BusAnimationSequence() {
|
public BusAnimationSequence() {
|
||||||
// Initialise our keyframe storage, since it's multidimensional
|
// Initialise our keyframe storage, since it's multidimensional
|
||||||
@ -68,7 +71,7 @@ public class BusAnimationSequence {
|
|||||||
|
|
||||||
//all transformation data is absolute, additive transformations have not yet been implemented
|
//all transformation data is absolute, additive transformations have not yet been implemented
|
||||||
public double[] getTransformation(int millis) {
|
public double[] getTransformation(int millis) {
|
||||||
double[] transform = new double[12];
|
double[] transform = new double[15];
|
||||||
|
|
||||||
for(int i = 0; i < 9; i++) {
|
for(int i = 0; i < 9; i++) {
|
||||||
List<BusAnimationKeyframe> keyframes = transformKeyframes.get(i);
|
List<BusAnimationKeyframe> keyframes = transformKeyframes.get(i);
|
||||||
@ -109,6 +112,10 @@ public class BusAnimationSequence {
|
|||||||
transform[10] = offset[1];
|
transform[10] = offset[1];
|
||||||
transform[11] = offset[2];
|
transform[11] = offset[2];
|
||||||
|
|
||||||
|
transform[12] = rotMode[0];
|
||||||
|
transform[13] = rotMode[1];
|
||||||
|
transform[14] = rotMode[2];
|
||||||
|
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -110,18 +110,20 @@ public class HbmAnimations {
|
|||||||
0, 0, 0, // position
|
0, 0, 0, // position
|
||||||
0, 0, 0, // rotation
|
0, 0, 0, // rotation
|
||||||
1, 1, 1, // scale
|
1, 1, 1, // scale
|
||||||
0, 0, 0 // offset
|
0, 0, 0, // offset
|
||||||
|
0, 1, 2, // XYZ order
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void applyRelevantTransformation(String bus) { applyRelevantTransformation(bus, 0); }
|
public static void applyRelevantTransformation(String bus) { applyRelevantTransformation(bus, 0); }
|
||||||
public static void applyRelevantTransformation(String bus, int index) {
|
public static void applyRelevantTransformation(String bus, int index) {
|
||||||
double[] transform = getRelevantTransformation(bus, index);
|
double[] transform = getRelevantTransformation(bus, index);
|
||||||
|
int[] rot = new int[] { (int)transform[12], (int)transform[13], (int)transform[14] };
|
||||||
|
|
||||||
GL11.glTranslated(transform[0], transform[1], transform[2]);
|
GL11.glTranslated(transform[0], transform[1], transform[2]);
|
||||||
GL11.glRotated(transform[3], 1, 0, 0);
|
GL11.glRotated(transform[3 + rot[0]], rot[0] == 0 ? 1 : 0, rot[0] == 1 ? 1 : 0, rot[0] == 2 ? 1 : 0);
|
||||||
GL11.glRotated(transform[4], 0, 1, 0);
|
GL11.glRotated(transform[3 + rot[1]], rot[1] == 0 ? 1 : 0, rot[1] == 1 ? 1 : 0, rot[1] == 2 ? 1 : 0);
|
||||||
GL11.glRotated(transform[5], 0, 0, 1);
|
GL11.glRotated(transform[3 + rot[2]], rot[2] == 0 ? 1 : 0, rot[2] == 1 ? 1 : 0, rot[2] == 2 ? 1 : 0);
|
||||||
GL11.glTranslated(-transform[9], -transform[10], -transform[11]);
|
GL11.glTranslated(-transform[9], -transform[10], -transform[11]);
|
||||||
GL11.glScaled(transform[6], transform[7], transform[8]);
|
GL11.glScaled(transform[6], transform[7], transform[8]);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user