<OBJECT ID="ScrollBar1" WIDTH=203 HEIGHT=16 CLASSID="CLSID:DFD181E0-5E2F-11CE-A449-00AA004A803D"> </OBJECT><PARAM NAME="Size" VALUE="5362;423"> <PARAM NAME="Max" VALUE="10"> <PARAM NAME="LargeChange" VALUE="2"> <PARAM NAME="Orientation" VALUE="1"> <script language="VBScript"> <!-- sub ScrollBar1_change() document.lhouse.setWindSpeed scrollbar1.value end sub --></script>
public ModifiableBehavior _windSpeed; Normalized value between 0 and 1
public ModifiableBehavior _windMode; public ModifiableBehavior _breezeInterval; public DXMEvent _grabEvent; public Vector3Bvr _originalPath; public Vector3Bvr _actualPath;
public void setWindSpeed(int val) { _windSpeed.switchTo( div(toBvr(val),toBvr(10)) ); _windMode.switchTo(mul(add(toBvr(val),toBvr(1)),toBvr(0.9))); }
public void createModel(BvrsToRun blist) {
_windSpeed = new ModifiableBehavior(toBvr(0)); _windMode = new ModifiableBehavior(toBvr(0)); _breezeInterval = new ModifiableBehavior(toBvr(2)); NumberBvr windSpeed = (NumberBvr)_windSpeed.getBvr();
NumberBvr windMode = (NumberBvr)_windMode.getBvr(); NumberBvr windDistance = integral(windSpeed); NumberBvr windAngle = generateWindAngle(blist); NumberBvr random = seededRandom(.11); blist.add(random);
private NumberBvr generateWindAngle(BvrsToRun blist) { ModifiableBehavior breezeAngle = new ModifiableBehavior(toBvr(0));
NumberBvr random = seededRandom(.27);
blist.add(random);
DXMEvent timerEv = timer((NumberBvr)_breezeInterval.getBvr());
timerEv = timerEv.snapshotEvent(random);
NumberBvr loop = NumberBvr.newUninitBvr();
UntilNotifier newBreeze = new Breeze((NumberBvr)_windSpeed.getBvr(), _breezeInterval, breezeAngle, loop); NumberBvr angle = (NumberBvr)breezeAngle.getBvr(); timerEv = andEvent(timerEv, timerEv.snapshotEvent(angle));
loop.init((NumberBvr)untilNotify(angle, timerEv, newBreeze));
return loop; }
private ModifiableBehavior _breezeInterval; private ModifiableBehavior _breezeAngle; private NumberBvr _windSpeed; private NumberBvr _loop; public Breeze(NumberBvr windSpeed, ModifiableBehavior breezeInterval, ModifiableBehavior breezeAngle, NumberBvr loop) { _windSpeed = windSpeed; _breezeInterval = breezeInterval; _breezeAngle = breezeAngle; _loop = loop; }
public Behavior notify(Object eventData, Behavior curBvr, BvrsToRun lst) {
NumberBvr random = (NumberBvr)((PairObject)eventData).getFirst();
NumberBvr oldAngle = (NumberBvr)((PairObject)eventData).getSecond();
NumberBvr deltaAngle = mul(toBvr(2), sub(random,toBvr(.5))); _breezeInterval.switchTo(mul(toBvr(5), random)); _breezeAngle.switchTo(add(oldAngle,deltaAngle)); NumberBvr changingAngle = add(oldAngle, mul(deltaAngle, DxmNumber.smooth0to1(toBvr(2)))); return (NumberBvr)until(changingAngle, timer(toBvr(2)), _loop); } } |