summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/RollBehavior.java
blob: 02543db5290892ffe1647e225cb95196ab6db08f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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
 */