| 4 | import java.util.HashMap; |
| 5 | |
| 6 | public class PosedModelPose implements IPosedModelFrame |
| 7 | { |
| 8 | public HashMap<String, PosedBone> bones = new HashMap<>(); |
| 9 | |
| 10 | public PosedModelPose(BaseFileManager fileManager, String file) |
| 11 | { |
| 12 | this(fileManager.getInternalFileContents(file)); |
| 13 | } |
| 14 | |
| 15 | public PosedModelPose(ArrayList<String> lines) |
| 16 | { |
| 17 | double time = 0; |
| 18 | |
| 19 | for (String line : lines) |
| 20 | { |
| 21 | if (line.startsWith("rotation ")) |
| 22 | { |
| 23 | String[] s = line.split(" "); |
| 24 | |
| 25 | this.getBone(s[1]).rotation = new PosedBone.BoneRotationPose |
| 26 | (time, Math.toRadians(Double.parseDouble(s[2])), Math.toRadians(Double.parseDouble(s[3])), Math.toRadians(Double.parseDouble(s[4]))); |
| 27 | } |
| 28 | else if (line.startsWith("translation ")) |
| 29 | { |
| 30 | String[] s = line.split(" "); |
| 31 | |
| 32 | this.getBone(s[1]).translation = new PosedBone.BoneTranslationPose |
| 33 | (time, Double.parseDouble(s[2]), Double.parseDouble(s[3]), Double.parseDouble(s[4])); |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | protected PosedBone getBone(String name) |
| 39 | { |
| 40 | if (!this.bones.containsKey(name)) |
| 41 | this.bones.put(name, new PosedBone(this, name)); |
| 42 | |
| 43 | return this.bones.get(name); |
| 44 | } |
| 45 | |
| 46 | public void apply(PosedModel m, double frac) |
| 47 | { |
| 48 | for (PosedBone b: this.bones.values()) |
| 49 | b.apply(m, frac); |
| 50 | } |
| 51 | |
| 52 | public static class PosedBone |
| 53 | { |
| 54 | public static BoneRotationPose defaultRotation = new BoneRotationPose(0, 0, 0, 0); |
| 55 | public static BoneTranslationPose defaultTranslation = new BoneTranslationPose(0, 0, 0, 0); |
| 56 | |
| 57 | public PosedModelPose animation; |
| 58 | public String name; |
| 59 | public BoneRotationPose rotation = defaultRotation; |
| 60 | public BoneTranslationPose translation = defaultTranslation; |
| 61 | |
| 62 | public PosedBone(PosedModelPose anim, String name) |
| 63 | { |
nothing calls this directly
no outgoing calls
no test coverage detected