diff --git a/src/animata/Controller.java b/src/animata/Controller.java index af0ae0d..b47b2d7 100644 --- a/src/animata/Controller.java +++ b/src/animata/Controller.java @@ -41,6 +41,10 @@ public boolean setJoint(String joint, float x, float y, float z) { } public boolean setBoneTempo(Scene scene, String name, Float tempo) { + if(scene == null){ + System.out.println("tried to access bone info before scene was added"); + return false; + } ArrayList bones = scene.findBones(name); for (Bone bone : bones) { bone.setTempo(tempo); diff --git a/src/animata/Scene.java b/src/animata/Scene.java index e704796..ccc196a 100644 --- a/src/animata/Scene.java +++ b/src/animata/Scene.java @@ -24,6 +24,7 @@ public class Scene implements Observer { private Layer layer; private Animator animator; public ArrayList bones; + public ArrayList layers; public Scene(XMLElement element, MidiInput in, PApplet applet, Layer layer) { this.in = in; @@ -37,6 +38,10 @@ public Scene(XMLElement element, MidiInput in, PApplet applet, Layer layer) { bones = new ArrayList(); layer.getAllBones(bones); + + layers = new ArrayList(); + layer.getAllLayers(layers); + } private void setupToggle() { diff --git a/src/animata/controls/BoneTempoKeys.java b/src/animata/controls/BoneTempoKeys.java index e8ed046..983e60c 100644 --- a/src/animata/controls/BoneTempoKeys.java +++ b/src/animata/controls/BoneTempoKeys.java @@ -21,7 +21,7 @@ public BoneTempoKeys(MidiInput in, int low, int high, String bone, float tempo, this.high = high; this.bone = bone; this.tempo = tempo; - Controller.getInstance().setBoneTempo(scene,bone, 0f); +// Controller.getInstance().setBoneTempo(scene,bone, 0f); } public BoneTempoKeys(XMLElement element, MidiInput in) { @@ -30,7 +30,7 @@ public BoneTempoKeys(XMLElement element, MidiInput in) { high = NoteParser.getNote(element.getStringAttribute("high", "100")); bone = element.getStringAttribute("bone"); tempo = element.getFloatAttribute("tempo"); - Controller.getInstance().setBoneTempo(scene,bone, 0f); +// Controller.getInstance().setBoneTempo(scene,bone, 0f); } public void noteOnReceived(Note n) { diff --git a/src/animata/controls/LayerRotator.java b/src/animata/controls/LayerRotator.java index 8c4b4d6..a890227 100644 --- a/src/animata/controls/LayerRotator.java +++ b/src/animata/controls/LayerRotator.java @@ -26,7 +26,7 @@ public void controllerChangeReceived(Controller controller){ if(controller.getChannel() != channel) return; if(controller.getCC() != cc) return; float value = range * (controller.getValue() / 127f) + min; - Layer.setRotation(layer, value); + Layer.setRotation(scene,layer, value); } diff --git a/src/animata/controls/LayerScaler.java b/src/animata/controls/LayerScaler.java index 3ba1f82..e8c04a0 100644 --- a/src/animata/controls/LayerScaler.java +++ b/src/animata/controls/LayerScaler.java @@ -26,7 +26,7 @@ public void controllerChangeReceived(Controller controller){ if(controller.getChannel() != channel) return; if(controller.getCC() != cc) return; float value = range * (controller.getValue() / 127f) + min; - Layer.setScale(layer, value); + Layer.setScale(scene, layer, value); } } diff --git a/src/animata/controls/NoteRangeAngle.java b/src/animata/controls/NoteRangeAngle.java index 57b4520..73f95cd 100644 --- a/src/animata/controls/NoteRangeAngle.java +++ b/src/animata/controls/NoteRangeAngle.java @@ -50,7 +50,7 @@ public void noteOnReceived(Note n) { animator.set(angle, FRAMES_TO_USE); } public void update(Observable o, Object arg) { - Layer.setRotation(layer, animator.currentValue); + Layer.setRotation(scene, layer, animator.currentValue); } } diff --git a/src/animata/controls/NoteRangeScale.java b/src/animata/controls/NoteRangeScale.java index 8465397..3206243 100644 --- a/src/animata/controls/NoteRangeScale.java +++ b/src/animata/controls/NoteRangeScale.java @@ -44,7 +44,7 @@ public void noteOffReceived(Note n) { animator.set(off, OUT_FRAMES); } public void update(Observable o, Object arg) { - Layer.setScale(layer, animator.currentValue); + Layer.setScale(scene, layer, animator.currentValue); } } diff --git a/src/animata/model/Layer.java b/src/animata/model/Layer.java index 2e21b23..699bccb 100644 --- a/src/animata/model/Layer.java +++ b/src/animata/model/Layer.java @@ -5,6 +5,7 @@ import javax.vecmath.Matrix3d; +import animata.Scene; import animata.ViewBase; import animata.model.Skeleton.Bone; import animata.model.Skeleton.Joint; @@ -128,12 +129,7 @@ public static void setAlpha(String name, Float value) { } - public static void setRotation(String name, float value) { - for(Layer layer : allLayers){ - if(layer.name != null && layer.name.equals(name)) layer.setRotation( value); - } - } private void setRotation(float value) { if(anchor == null) anchor = findAnchor(); @@ -153,12 +149,6 @@ private Joint findAnchor() { return null; } - public static void setScale(String name, float value) { - for(Layer layer : allLayers){ - if(layer.name != null && layer.name.equals(name)) layer.setScale(value); - } - - } private void setScale(float value) { scale = value; @@ -173,4 +163,25 @@ public void getAllBones(ArrayList bones) { bones.addAll(skeleton.bones); } + public static void setScale(Scene scene, String name, float value) { + for(Layer layer : scene.layers){ + if(layer.name != null && layer.name.equals(name)) layer.setScale(value); + } + + } + + public void getAllLayers(ArrayList result) { + for(Layer layer : layers){ + layer.getAllLayers(result); + } + result.addAll(layers); + } + + public static void setRotation(Scene scene, String name, float value) { + for(Layer layer : scene.layers){ + if(layer.name != null && layer.name.equals(name)) layer.setRotation( value); + } + + } + }