class RandomNode extends Composite { static final long serialVersionUID = 6286502202432779788L; // ? -9091094008965972116L; // prior to new behavior: -5041564709139164666 RandomNode() { this("Random"); } RandomNode(String name) { super(name); } Object3D deepCopy() { Composite comp = new RandomNode(); deepCopySelf(comp); return comp; } // public int Size() // { // return 1; // } public int size() { if (CameraPane.RANDOM) { if (super.size() > 0) return 1; else return 0; } else return super.size(); } int rnd = -1; static int globalseed = 0; static int globalseed2 = 0; // mocap frames??? //static transient int whatevercount = 0; void ResetRandom() { whatevercount = 0; super.ResetRandom(); } int firstchoice = 0; // int currentpass = 0; public Object3D reserve(int i) { if (!CameraPane.RANDOM) return super.reserve(i); //assert(rnd == -1); // if (!link2master && rnd != -1) // new Exception().printStackTrace(); if (link2master && rnd != -1) // freeze current value return super.reserve(rnd); if (firstchoice == 0) firstchoice = (int)(Math.random()*super.Size()) + 1; // if (currentpass != CameraPane.renderpass) // { // currentpass = CameraPane.renderpass; // globalcount = firstchoice-1; // //System.err.println("firstchoice = " + firstchoice); // } //System.err.println("currentpass = " + currentpass); //System.err.println("renderpass = " + CameraPane.renderpass); //System.err.println("globalcount = " + globalcount); int gcount = globalseed; if (Size() > 0 && get(0) instanceof FrameSelector) { gcount = globalseed2; } //int tabarnak = super.Size(); rnd = gcount%super.Size(); // //(int)(Math.random()*super.size()); //globalcount++; gcount += GrafreeD.mix3(rnd+12345,firstchoice*12345,gcount); gcount &= 0x7fffffff; if (Size() > 0 && get(0) instanceof FrameSelector) globalseed2 = gcount; else globalseed = gcount; if (!random) // aout 2013 link2master) rnd = whatevercount++; rnd %= super.Size(); //GraphreeD.tracein("RESERVE " + this + " = ", i); Object3D child = super.get(rnd); //Applet3D.tracein("RESERVE ", child); child.count--; //assert (child.count >= 0); return child; } public Object3D reserve0(int i) { return reserve(i); } public void release(int i) { if (!CameraPane.RANDOM) { super.release(i); return; } //GraphreeD.traceout("RELEASE " + this + " = ", i); // Object3D child = super.get(i); // //Applet3D.traceout("RELEASE ", child); // child.count++; // globalcount--; super.get(rnd).count++; //assert (child.count >= 0); if (!link2master) // volatile value rnd = -1; } void createEditWindow(GroupEditor callee, boolean newWindow) { //editWindow = (new SphereEditor(this, deepCopy(), callee)).GetEditor(); if (newWindow) { objectUI = new RandomEditor(this, deepCopy(), callee); } else { objectUI = new RandomEditor(this, callee); } editWindow = objectUI.GetEditor(); } }