mouse_sens = .5
tightness = 2
gravity = .005
lass = .94
power = -0.3
CONST pip180
= 3.141592 / 180
points_c_arr = 2000
conn_c_arr = 2000
DIM SHARED points
(points_c_arr
, 19), conn
(conn_c_arr
, 9), cam
(19), me
(19), conn_c
, points_c
make_grid 1, -10, -10, 10, 10, -10, 0, -10, 10, 0, 10, 10, 0, 1.2
'make_sphere 2, 0, 10, 0, 5, 8 'ident,X,Y,Z,RAD,POINTS
'control
me
(2) = me
(2) + mw: me
(3) = me
(3) - mousex
* mouse_sens: me
(4) = me
(4) + mousey
* mouse_sens:
IF ABS(me
(4)) > 80 THEN me
(4) = 80 * SGN(me
(4)) go
= -.5 * ABS(k_left
OR k_right
OR k_up
OR k_down
): go_ang
= -90 * (k_left
- k_right
) + (me
(3)) - 90 ang1
= go_ang
* pip180: ang2
= (90 - me
(4)) * pip180:
IF k_down
THEN go
= -go
me
(0) = me
(0) + SIN(ang2
) * COS(ang1
) * go: me
(1) = me
(1) + SIN(ang2
) * SIN(ang1
) * go: me
(2) = me
(2) + COS(ang2
) * go
FOR t
= 0 TO 9: cam
(t
) = me
(t
):
NEXT t: cam
(13) = cam
(3) * pip180: cam
(14) = cam
(4) * pip180
'calculate moving
'connections vector
vec(0) = 0: vec(1) = 0: vec(2) = 0: vec_c = 0
x
= -1:
FOR t2
= 0 TO 1:
IF conn
(t
, t2
) = a
THEN x
= conn
(t
, t2
XOR 1) FOR av
= 0 TO 2: disv
= points
(a
, av
) - points
(x
, av
): vec
(av
) = vec
(av
) + ((ABS(disv
) - conn
(t
, 4 + av
))) * SGN(disv
) * power
NEXT av: vec_c
= vec_c
+ 1
FOR av
= 0 TO 2: points
(a
, 3 + av
) = (points
(a
, 3 + av
) + vec
(av
) / vec_c
) * lass:
NEXT av: points
(a
, 4) = points
(a
, 4) - gravity
FOR av
= 0 TO 2: points
(a
, 11 + av
) = points
(a
, av
) + points
(a
, 3 + av
):
NEXT av
FOR a
= 0 TO points_c_arr
- 1:
FOR t
= 0 TO 2: points
(a
, t
) = points
(a
, 11 + t
):
NEXT t
, a
rand
= 30:
FOR t
= 0 TO 2: points
(a
, t
) = points
(a
, t
) + rand
* RND(1) - rand
/ 2:
NEXT t
'calculating points
points(ap, 8) = points(ap, 0): points(ap, 9) = points(ap, 1): points(ap, 10) = points(ap, 2)
rotate_display points
(ap
, 8), points
(ap
, 9), points
(ap
, 10):
NEXT ap
'draw connections
FOR t1
= 0 TO 1:
FOR t2
= 0 TO 2: coo
(t1
, t2
) = points
(conn
(ac
, t1
), 8 + t2
):
NEXT t2
, t1
line_3d coo(0, 0), coo(0, 1), coo(0, 2), coo(1, 0), coo(1, 1), coo(1, 2)
'fix points draw signal
FOR t2
= 0 TO 2: coo
(0, t2
) = points
(ap
, 8 + t2
):
NEXT t2
point3d_to_pset coo
(0, 0), coo
(0, 1), coo
(0, 2):
CIRCLE (coo
(0, 0), coo
(0, 1)), 12000 / coo
(0, 2)
SUB line_3d
(x0
, y0
, z0
, x1
, y1
, z1
) IF z0
< -1 AND z1
< -1 THEN point3d_to_pset x0
, y0
, z0: point3d_to_pset x1
, y1
, z1:
LINE (x0
, y0
)-(x1
, y1
)
SUB point3d_to_pset
(x
, y
, z
): multi
= 400: zlimit
= -2: x
= monx
/ 2 + (x
+ zlimit
) / -z
* multi: y
= mony
/ 2 + (y
+ zlimit
) / z
* multi
grey
= 255 - ABS(z
) * .1:
IF grey
< 10 THEN grey
= 10
SUB make_grid
(acc
, x0
, y0
, z0
, x1
, y1
, z1
, x2
, y2
, z2
, x3
, y3
, z3
, res
): p_start
= points_c
resA
= INT((dis
(x0
- x1
, y0
- y1
, z0
- z1
) + dis
(x2
- x3
, y2
- y3
, z2
- z3
)) / 2 / res
) resB
= INT((dis
(x0
- x2
, y0
- y2
, z0
- z2
) + dis
(x1
- x3
, y1
- y3
, z1
- z3
)) / 2 / res
) FOR a
= 0 TO resA
- 1: n
= 1 / resA
* a
tx1 = scale(x0, x1, n): ty1 = scale(y0, y1, n): tz1 = scale(z0, z1, n): tx2 = scale(x2, x3, n): ty2 = scale(y2, y3, n): tz2 = scale(z2, z3, n)
FOR b
= 0 TO resB
- 1: n
= 1 / resB
* b: l
= p_start
+ b
* resA
+ a
points(l, 0) = scale(tx1, tx2, n): points(l, 2) = scale(ty1, ty2, n): points(l, 1) = scale(tz1, tz2, n)
points
(l
, 6) = 1: points
(l
, 7) = acc: points
(l
, 14) = 1:
IF (a
= 0 OR a
= resA
- 1) AND (b
= 0 OR b
= resB
- 1) THEN points
(l
, 14) = 0 FOR ty
= 0 TO resB
- 1:
FOR tx
= 0 TO resA
- 2: p1
= tx
+ ty
* resA: conn_add p1
, p1
+ 1, tightness:
NEXT tx
, ty
FOR tx
= 0 TO resA
- 1:
FOR ty
= 0 TO resB
- 2: p1
= tx
+ ty
* resA: conn_add p1
, p1
+ resA
, tightness:
NEXT ty
, tx
points_c = points_c + resA * resB
NEXT t:
REDIM disx
(2): conn
(conn_c
, 0) = p1: conn
(conn_c
, 1) = p2
FOR t
= 0 TO 2: conn
(conn_c
, 4 + t
) = (ABS(points
(p1
, t
) - points
(p2
, t
))) * tightness:
NEXT t
conn(conn_c, 2) = dis(conn(conn_c, 4), conn(conn_c, 5), conn(conn_c, 6)): conn(conn_c, 3) = 1: conn_c = conn_c + 1
SUB rotate_2d
(x
, y
, ang
): x1
= x
* COS(ang
) - y
* SIN(ang
): y1
= x
* SIN(ang
) + y
* COS(ang
): x
= x1: y
= y1:
END SUB SUB rotate_display
(x
, y
, z
) x = (x - cam(0)) * 100: y = (y - cam(2)) * 100: z = -(z - cam(1)) * 100: rotate_2d x, z, cam(13): rotate_2d y, z, cam(14)
FUNCTION degree
(a
, b
): degreex
= ATN(a
/ (b
+ .00001)) / pip180: degreex
= degreex
- 180 * ABS(0 > b
): degreex
= degreex
- 360 * (degreex
< 0): degree
= degreex:
END FUNCTION
'POINTS array
'0,1,2 : X,Y,Z
'3,4,5 : X,Y,Z vector
'6:active 7:identifier
'8,9,10 :X,Y,Z calculated to maptriangle
'11,12,13 :X,Y,Z moving temporary calculating
'14: 0:FIX 1:MOVING
'CONN array
'0:point#1
'1:point#2
'2:distance
'3:active
'4:disX
'5:disY
'6:disZ