MCPcopy Create free account
hub / github.com/aehmttw/Tanks / PosedModelAnimation

Class PosedModelAnimation

src/main/java/basewindow/PosedModelAnimation.java:6–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import java.util.HashMap;
5
6public class PosedModelAnimation implements IPosedModelFrame
7{
8 public double duration;
9 public boolean looped;
10 public boolean cubic = true;
11
12 public HashMap<String, AnimatedBone> bones = new HashMap<>();
13
14 public PosedModelAnimation(BaseFileManager fileManager, String file)
15 {
16 this(fileManager.getInternalFileContents(file));
17 }
18
19 public PosedModelAnimation(ArrayList<String> lines)
20 {
21 double time = 0;
22
23 for (String line : lines)
24 {
25 if (line.startsWith("duration "))
26 {
27 duration = 100 * Double.parseDouble(line.split(" ")[1]);
28 looped = line.contains("looped");
29 }
30 else if (line.startsWith("time "))
31 time = 100 * Double.parseDouble(line.split(" ")[1]);
32 else if (line.startsWith("rotation "))
33 {
34 String[] s = line.split(" ");
35
36 this.getBone(s[1]).rotationFrames.add(new AnimatedBone.AnimatedBoneRotationFrame
37 (time, Math.toRadians(Double.parseDouble(s[2])), Math.toRadians(Double.parseDouble(s[3])), Math.toRadians(Double.parseDouble(s[4]))));
38 }
39 else if (line.startsWith("translation "))
40 {
41 String[] s = line.split(" ");
42
43 this.getBone(s[1]).translationFrames.add(new AnimatedBone.AnimatedBoneTranslationFrame
44 (time, Double.parseDouble(s[2]), -Double.parseDouble(s[3]), Double.parseDouble(s[4])));
45 }
46 else if (line.startsWith("interpolation "))
47 {
48 String[] s = line.split(" ");
49
50 if (s[1].equals("linear"))
51 cubic = false;
52 else if (s[1].equals("cubic"))
53 cubic = true;
54 }
55 }
56 }
57
58 protected AnimatedBone getBone(String name)
59 {
60 if (!this.bones.containsKey(name))
61 this.bones.put(name, new AnimatedBone(this, name));
62
63 return this.bones.get(name);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected