1 package edu.berkeley.qfat.geom;
2 import javax.media.opengl.*;
5 public class BindingGroup<T extends HasBindingGroup> {
7 private T master = null;
8 private HashMap<T,Matrix> matrices = new HashMap<T,Matrix>();
10 public BindingGroup(T master) {
12 matrices.put(master, Matrix.ONE);
15 public void merge(BindingGroup<T> bg, Matrix m) {
16 for(HasBindingGroup hbg : bg.matrices.keySet()) {
17 matrices.put((T)hbg, bg.matrices.get(hbg).times(m));
18 hbg.bindingGroup = this;
24 public T getMaster() { return master; }
25 public Matrix getMatrix(T t) { return matrices.get(t); }
27 // t1 = getMatrix(t1) * master
28 // getMatrix(t2)^-1 * t2 = master
29 // t1 = getMatrix(t1) * getMatrix(t2)^-1 * t2
30 /** t1 = getMatrix(t1, t2) * t2 */
31 public Matrix getMatrix(T t1, T t2) {
32 return getMatrix(t1).times(getMatrix(t2).inverse());