Skip to content

Commit

Permalink
made layers isolated
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelforrest committed Jun 28, 2009
1 parent 250104d commit ce1a70b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 17 deletions.
4 changes: 4 additions & 0 deletions src/animata/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Bone> bones = scene.findBones(name);
for (Bone bone : bones) {
bone.setTempo(tempo);
Expand Down
5 changes: 5 additions & 0 deletions src/animata/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Scene implements Observer {
private Layer layer;
private Animator animator;
public ArrayList<Bone> bones;
public ArrayList<Layer> layers;

public Scene(XMLElement element, MidiInput in, PApplet applet, Layer layer) {
this.in = in;
Expand All @@ -37,6 +38,10 @@ public Scene(XMLElement element, MidiInput in, PApplet applet, Layer layer) {

bones = new ArrayList<Bone>();
layer.getAllBones(bones);

layers = new ArrayList<Layer>();
layer.getAllLayers(layers);

}

private void setupToggle() {
Expand Down
4 changes: 2 additions & 2 deletions src/animata/controls/BoneTempoKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/animata/controls/LayerRotator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
2 changes: 1 addition & 1 deletion src/animata/controls/LayerScaler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
2 changes: 1 addition & 1 deletion src/animata/controls/NoteRangeAngle.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
}
2 changes: 1 addition & 1 deletion src/animata/controls/NoteRangeScale.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
33 changes: 22 additions & 11 deletions src/animata/model/Layer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import javax.vecmath.Matrix3d;

import animata.Scene;
import animata.ViewBase;
import animata.model.Skeleton.Bone;
import animata.model.Skeleton.Joint;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand All @@ -173,4 +163,25 @@ public void getAllBones(ArrayList<Bone> 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<Layer> 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);
}

}

}

0 comments on commit ce1a70b

Please sign in to comment.