It's actually not much(It's what a transformGroup would be doing anyways), so here is it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| public class DisplaySync implements DisplayTransformable { Matrix4f diff; Matrix4f temp; TransformGroup g; Transform3D t; public DisplaySync(TransformGroup g, Placeable p) { this.g = g; t = g.getTransform(); diff = new Matrix4f(); temp = new Matrix4f(); t.get(temp); if(p instanceof GeomTransform) { diff = new Matrix4f(); ((GeomTransform) p).getTransform(diff); } else diff.set(p.getQuaternion(), p.getPosition(),1); diff.invert(); diff.mul(temp); }
public void setTransform(Vector3f position, Quat4f quaternion) { temp.set(quaternion, position, 1); temp.mul(diff); t.set(temp); g.setTransform(t); } } |