summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/RollBehavior.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/scape/RollBehavior.java')
-rw-r--r--NET/worlds/scape/RollBehavior.java123
1 files changed, 123 insertions, 0 deletions
diff --git a/NET/worlds/scape/RollBehavior.java b/NET/worlds/scape/RollBehavior.java
new file mode 100644
index 0000000..02543db
--- /dev/null
+++ b/NET/worlds/scape/RollBehavior.java
@@ -0,0 +1,123 @@
+/* */ package NET.worlds.scape;
+/* */
+/* */ import java.io.IOException;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public class RollBehavior
+/* */ extends VelocityBehavior
+/* */ {
+/* */ public float rollFactor;
+/* */ private long lastTime;
+/* */ private float bumpFraction;
+/* */
+/* */ public RollBehavior(Point3Temp vel, float diameter)
+/* */ {
+/* 32 */ super(vel, 0.0F, Point3Temp.make(0.0F, 0.0F, 1.0F), 0.0F, 0.0F);
+/* 33 */ this.rollFactor = (360.0F / (3.1416F * diameter));
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public RollBehavior() {}
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public boolean handle(FrameEvent e)
+/* */ {
+/* 49 */ float vel = this.linearVel;
+/* 50 */ float dT = (float)(e.time - this.lastTime) / 1000.0F;
+/* 51 */ this.bumpFraction = 1.0F;
+/* 52 */ super.handle(e);
+/* 53 */ if ((vel != 0.0F) && (this.lastTime != 0L))
+/* 54 */ e.receiver.worldSpin(-this.dir.y, this.dir.x, this.dir.z,
+/* 55 */ this.dir.length() * dT * vel * this.rollFactor * this.bumpFraction);
+/* 56 */ this.lastTime = e.time;
+/* 57 */ return true;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public boolean handle(BumpEventTemp b)
+/* */ {
+/* 66 */ this.bumpFraction = b.fraction;
+/* 67 */ return super.handle(b);
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ public Object properties(int index, int offset, int mode, Object value)
+/* */ throws NoSuchPropertyException
+/* */ {
+/* 76 */ Object ret = null;
+/* 77 */ switch (index - offset) {
+/* */ case 0:
+/* 79 */ if (mode == 0) {
+/* 80 */ ret = FloatPropertyEditor.make(
+/* 81 */ new Property(this, index, "Roll Factor"));
+/* 82 */ } else if (mode == 1) {
+/* 83 */ ret = new Float(this.rollFactor);
+/* 84 */ } else if (mode == 2)
+/* 85 */ this.rollFactor = ((Float)value).floatValue();
+/* 86 */ break;
+/* */ default:
+/* 88 */ ret = super.properties(index, offset + 1, mode, value);
+/* */ }
+/* 90 */ return ret;
+/* */ }
+/* */
+/* 93 */ private static Object classCookie = new Object();
+/* */
+/* */ public void saveState(Saver s) throws IOException
+/* */ {
+/* 97 */ s.saveVersion(0, classCookie);
+/* 98 */ super.saveState(s);
+/* 99 */ s.saveFloat(this.rollFactor);
+/* */
+/* 101 */ s.saveFloat(this.bumpFraction);
+/* */ }
+/* */
+/* */ public void restoreState(Restorer r) throws IOException, TooNewException
+/* */ {
+/* 106 */ switch (r.restoreVersion(classCookie)) {
+/* */ case 0:
+/* 108 */ super.restoreState(r);
+/* 109 */ this.rollFactor = r.restoreFloat();
+/* */
+/* 111 */ this.bumpFraction = r.restoreFloat();
+/* 112 */ break;
+/* */ default:
+/* 114 */ throw new TooNewException();
+/* */ }
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\RollBehavior.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file