|
1 /* |
|
2 * This file is part of the TraKERS\Front Processing package. |
|
3 * |
|
4 * (c) IRI <http://www.iri.centrepompidou.fr/> |
|
5 * |
|
6 * For the full copyright and license information, please view the LICENSE_FRONT |
|
7 * file that was distributed with this source code. |
|
8 */ |
|
9 |
|
10 class vsquare |
|
11 { |
|
12 int x; |
|
13 int y; |
|
14 float xvel; |
|
15 float yvel; |
|
16 float col; |
|
17 |
|
18 vsquare(int xIn,int yIn) |
|
19 { |
|
20 x = xIn; |
|
21 y = yIn; |
|
22 } |
|
23 |
|
24 void addbuffer(int i, int u) |
|
25 { |
|
26 if(i>0 && i<lwidth && u>0 && u<lheight) |
|
27 { |
|
28 xvel += (vbuf[i-1][u-1].pressure*0.5 |
|
29 +vbuf[i-1][u].pressure |
|
30 +vbuf[i-1][u+1].pressure*0.5 |
|
31 -vbuf[i+1][u-1].pressure*0.5 |
|
32 -vbuf[i+1][u].pressure |
|
33 -vbuf[i+1][u+1].pressure*0.5 |
|
34 )*0.25; |
|
35 yvel += (vbuf[i-1][u-1].pressure*0.5 |
|
36 +vbuf[i][u-1].pressure |
|
37 +vbuf[i+1][u-1].pressure*0.5 |
|
38 -vbuf[i-1][u+1].pressure*0.5 |
|
39 -vbuf[i][u+1].pressure |
|
40 -vbuf[i+1][u+1].pressure*0.5 |
|
41 )*0.25; |
|
42 } |
|
43 } |
|
44 |
|
45 void updatevels(int mvelX, int mvelY, TuioPoint pt) |
|
46 { |
|
47 if(pt != null) |
|
48 { |
|
49 float adj = x - pt.getX(); |
|
50 float opp = y - pt.getY(); |
|
51 float dist = sqrt(opp*opp + adj*adj); |
|
52 if(dist < PENSIZE) |
|
53 { |
|
54 if(dist < 4) dist = PENSIZE; |
|
55 float mod = PENSIZE/dist; |
|
56 xvel += mvelX*mod; |
|
57 yvel += mvelY*mod; |
|
58 } |
|
59 } |
|
60 |
|
61 xvel *= 0.99; |
|
62 yvel *= 0.99; |
|
63 } |
|
64 |
|
65 void display(int i, int u) |
|
66 { |
|
67 float tcol = 0; |
|
68 if(col > 255) col = 255; |
|
69 if(i>0 && i<lwidth-1 && u>0 && u<lheight-1) |
|
70 { |
|
71 tcol = (+ v[i][u+1].col + v[i+1][u].col + v[i+1][u+1].col*0.5)*0.4; |
|
72 tcol = (int)(tcol+col*0.5); |
|
73 } |
|
74 else |
|
75 { |
|
76 tcol = (int)col; |
|
77 } |
|
78 fill(tcol, tcol, tcol); |
|
79 rect(x,y,RES,RES); |
|
80 //col = 32; |
|
81 } |
|
82 } |