class OctInterface { OctTree Tree; Register[] Register; OctNode[] Node; OctInterface( OctTree tree ) { this.Tree = tree; ArrayList leaves = Tree.GetLeafNodes(); int numRegisters = leaves.size(); Register = new Register[numRegisters]; for( int i = 0; i < numRegisters; i++ ) { Register[i] = new Register( (OctNode)leaves.get(i), 10, 20 ); } ArrayList nodes = Tree.GetAllNodes(); int numNodes = nodes.size(); Node = new OctNode[numNodes]; for( int i = 0; i < numNodes; i++ ) { Node[i] = (OctNode)nodes.get(i); } } void AssignColors() { int colorSetIndex = (int)random(2); Palette pal = (Palette)ColorSet.get(colorSetIndex); ArrayList nodes = Tree.GetAllNodes(); for( int i = 0; i < nodes.size(); i++ ) { ((OctNode)nodes.get(i)).Color = pal.GetRand(); } } void Update( GameTime gameTime ) { Tree.Root.Update(gameTime.Delta); } void Draw( GameTime gameTime ) { Tree.Root.Draw(); } } // Takes an input, Normalizes it, and maps it to a Node. // Acts as a general gatekeepr to a node, so the OctNode code can remain fairly agnostic to use. class Register { float Min; float Max; float Value; OctNode Node; Register(OctNode Target, float Min, float Max ) { this.Node = Target; this.Min = Min; this.Max = Max; } void Tap(float value, int Delta ) { Value = linstep( value, Min, Max ); if ( value > Min ) { Node.Tap( Value ); } } }