class RandomNode extends Composite { static final long serialVersionUID = 6286502202432779788L; // ? -9091094008965972116L; // prior to new behavior: -5041564709139164666 RandomNode() { this("Switch"); } RandomNode(String name) { super(name); } Object3D deepCopy() { Composite comp = new RandomNode(); deepCopySelf(comp); return comp; } protected void deepCopyNode(Object3D other) { super.deepCopyNode(other); RandomNode bp = (RandomNode)other; bp.rndIndex = rndIndex; bp.damp = damp; bp.firstchoice = firstchoice; } // public int Size() // { // return 1; // } boolean IsSwitch() { return CameraPane.SWITCH && !this.link2master; } public int size() { if (IsSwitch()) { if (super.size() > 0) return 1; else return 0; } else return super.size(); } void addChild(Object3D child) { super.addChild(child); this.rndIndex = Size() - 1; if (this.editWindow != null) { ((RandomEditor)this.objectUI).refreshContents(); } } int rndIndex = -1; static int globalseed = 0; static int globalseed2 = 0; // mocap frames??? //static transient int whatevercount = 0; void ResetRandom() { whatevercount = 0; super.ResetRandom(); } int damp; transient int countdamp; transient int globaloffset; void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) { if (live && Globals.isLIVE() && (display.DrawMode() == display.SHADOW || !Globals.RENDERSHADOW) && currentframe != Globals.framecount) { currentframe = Globals.framecount; if (countdamp <= 0) { countdamp = damp; globaloffset += 1; } else { if (CameraPane.FAST) countdamp -= CameraPane.STEP; else countdamp--; } } super.DrawNode(display, root, selected); } int firstchoice = 0; // int currentpass = 0; public Object3D reserve(int i) { if (!IsSwitch()) return super.reserve(i); //assert(rnd == -1); // if (!link2master && rnd != -1) // new Exception().printStackTrace(); if (!random && rndIndex != -1) // freeze current value return super.reserve(rndIndex); 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(); rndIndex = gcount%super.Size(); // //(int)(Math.random()*super.size()); //globalcount++; gcount += Grafreed.mix3(rndIndex+12345,firstchoice*12345,gcount); gcount &= 0x7fffffff; if (Size() > 0 && get(0) instanceof FrameSelector) globalseed2 = gcount; else globalseed = gcount; if (!random) // aout 2013 link2master) rndIndex = whatevercount++; if (live) // aout 2019 { rndIndex += globaloffset; } rndIndex %= super.Size(); //GraphreeD.tracein("RESERVE " + this + " = ", i); Object3D child = super.get(rndIndex); //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 (!IsSwitch()) { super.release(i); return; } //GraphreeD.traceout("RELEASE " + this + " = ", i); // Object3D child = super.get(i); // //Applet3D.traceout("RELEASE ", child); // child.count++; // globalcount--; super.get(rndIndex).count++; //assert (child.count >= 0); if (random) // volatile value rndIndex = -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(); } }