DIM terep
(39999, 49), pont
(39999, 49), kellkocka
(99, 99, 99) CONST pip180
= 3.1415 / 180
res3dx = 1024
res3dy = 768
ivx = 200 'X-dimension size
ivy = 200 'Y-dimension size
ivz = 200 'Z-dimension size
ks = .1 '1 box size
kockadb = 1600 'piece of cubes
msens = .3 'mouse sensitive
'create box texture
LINE (0, 0)-(199, 199), , B
, _RGB32(255, 255, 255)
'if you have a picture, use this
'kep(0) = _LOADIMAGE("d:\3dtext.bmp", 33)
kezdpontkocka = pontdb: pontdb = pontdb + kockadb * 8
kezdterepkocka = terepdb: terepdb = terepdb + kockadb * 6
GOSUB objadd
'3d data to array for boxes
lepes = 2: 'speed me
px
= 0: py
= 0: pz
= 0:
GOSUB enlepes
GOSUB egerkezelo: en
(0) = en
(0) + px
* lepes: en
(1) = en
(1) + py
* lepes: en
(2) = en
(2) + pz
* lepes
szorzo = 10
x0 = pont(terep(t, 0), 20) * szorzo
y0 = pont(terep(t, 0), 21) * szorzo
z0 = -pont(terep(t, 0), 22) * szorzo + addz
x1 = pont(terep(t, 1), 20) * szorzo
y1 = pont(terep(t, 1), 21) * szorzo
z1 = -pont(terep(t, 1), 22) * szorzo + addz
x2 = pont(terep(t, 2), 20) * szorzo
y2 = pont(terep(t, 2), 21) * szorzo
z2 = -pont(terep(t, 2), 22) * szorzo + addz
x3 = pont(terep(t, 3), 20) * szorzo
y3 = pont(terep(t, 3), 21) * szorzo
z3 = -pont(terep(t, 3), 22) * szorzo + addz
akep = terep(t, 4)
sx0 = terep(t, 5)
sy0 = terep(t, 6)
sx1 = terep(t, 7)
sy1 = terep(t, 8)
sx2 = terep(t, 9)
sy2 = terep(t, 10)
sx3 = terep(t, 11)
sy3 = terep(t, 12)
limit = 12000
felt1
= x1
> -limit
AND x1
< limit: felt2
= x2
> -limit
AND x2
< limit
felt3
= x3
> -limit
AND x3
< limit: felt4
= x4
> -limit
AND x4
< limit
felt5
= y1
> -limit
AND y1
< limit: felt6
= y2
> -limit
AND y2
< limit
felt7
= y3
> -limit
AND y3
< limit: felt8
= y4
> -limit
AND y4
< limit
felt9
= z1
< 1 AND z1
> -10000: felt10
= z2
< 1 AND z2
> -10000 felt11
= z3
< 1 AND z3
> -10000: felt12
= z4
< 1 AND z4
> -10000 feltb
= (felt9
AND felt10
) AND (felt11
AND felt12
)
_MAPTRIANGLE (sx0
, sy0
)-(sx1
, sy1
)-(sx2
, sy2
), kep
(akep
) TO(x0
, y0
, z0
)-(x1
, y1
, z1
)-(x2
, y2
, z2
), , _SMOOTH _MAPTRIANGLE (sx3
, sy3
)-(sx1
, sy1
)-(sx2
, sy2
), kep
(akep
) TO(x3
, y3
, z3
)-(x1
, y1
, z1
)-(x2
, y2
, z2
), , _SMOOTH
LOCATE 2, 1:
PRINT "en5"; en
(5);
"en6"; en
(6);
"en7"; en
(7)
egerkezelo:
makt = 0: mousex = 0: mousey = 0
en(3) = en(3) - mousey * msens
en(4) = en(4) + (mousex * msens) * neg
zslimit = 89
IF en
(3) >= 360 THEN en
(3) = 0 IF en
(4) >= 360 THEN en
(4) = 0
enlepes:
x5
= SIN(pip180
* en
(4)) * 1x7
= COS(pip180
* en
(4)) * 1neg
= SGN(COS(en
(3) * pip180
))x5 = neg * x5: x7 = neg * x7
x6
= (SIN(pip180
* en
(3)) * 3)
en(5) = 1 / s * x5
en(6) = 1 / s * x6
en(7) = 1 / s * x7
pontcalc:
x = pont(t, 0) - en(0): y = pont(t, 1) - en(1): z = pont(t, 2) - en(2)
rotx = pip180 * en(3): rotz = 0: roty = pip180 * en(4)
x2
= (x
* COS(rotz
)) - (y
* SIN(rotz
)) y2
= (x
* SIN(rotz
)) + (y
* COS(rotz
)) x3
= (x2
* COS(roty
)) - (z
* SIN(roty
)) z2
= (x2
* SIN(roty
)) + (z
* COS(roty
)) y3
= (y2
* COS(rotx
)) - (z2
* SIN(rotx
)) z3
= (y2
* SIN(rotx
)) + (z2
* COS(rotx
)) pont(t, 20) = x3: pont(t, 21) = y3: pont(t, 22) = z3
t = 5
qx = pont(t, 20) - pont(t, 0)
qy = pont(t, 21) - pont(t, 1)
qz = pont(t, 22) - pont(t, 2)
objadd:
koc(0, 0) = -1
koc(0, 1) = -1
koc(0, 2) = -1
koc(1, 0) = 1
koc(1, 1) = -1
koc(1, 2) = -1
koc(2, 0) = -1
koc(2, 1) = 1
koc(2, 2) = -1
koc(3, 0) = 1
koc(3, 1) = 1
koc(3, 2) = -1
koc(4, 0) = -1
koc(4, 1) = -1
koc(4, 2) = 1
koc(5, 0) = 1
koc(5, 1) = -1
koc(5, 2) = 1
koc(6, 0) = -1
koc(6, 1) = 1
koc(6, 2) = 1
koc(7, 0) = 1
koc(7, 1) = 1
koc(7, 2) = 1
kellkocka(lehetx, lehety, lehetz) = 1: ap = kezdpontkocka + t * 8
pont(ap + t2, 0) = lehetx * ks + koc(t2, 0) * ks / 2 - ivx / 2
pont(ap + t2, 1) = lehety * ks + koc(t2, 1) * ks / 2 - ivy / 2
pont(ap + t2, 2) = lehetz * ks + koc(t2, 2) * ks / 2 - ivz / 2
at = kezdterepkocka + t * 6
atx
= at
+ 0: p1
= ap
+ 0: p2
= ap
+ 1: p3
= ap
+ 2: p4
= ap
+ 3:
GOSUB terepmake
atx
= at
+ 1: p1
= ap
+ 5: p2
= ap
+ 4: p3
= ap
+ 7: p4
= ap
+ 6:
GOSUB terepmake
atx
= at
+ 2: p1
= ap
+ 1: p2
= ap
+ 5: p3
= ap
+ 3: p4
= ap
+ 7:
GOSUB terepmake
atx
= at
+ 3: p1
= ap
+ 4: p2
= ap
+ 0: p3
= ap
+ 6: p4
= ap
+ 2:
GOSUB terepmake
atx
= at
+ 4: p1
= ap
+ 4: p2
= ap
+ 5: p3
= ap
+ 0: p4
= ap
+ 1:
GOSUB terepmake
atx
= at
+ 5: p1
= ap
+ 7: p2
= ap
+ 6: p3
= ap
+ 3: p4
= ap
+ 2:
GOSUB terepmake
terepmake:
terep(atx, 0) = p1
terep(atx, 1) = p2
terep(atx, 2) = p3
terep(atx, 3) = p4
terep
(atx
, 4) = 0:
REM kep azonosito
terep(atx, 5) = 0
terep(atx, 6) = 0
terep
(atx
, 7) = _WIDTH(kep
(0)) - 1terep(atx, 8) = 0
terep(atx, 9) = 0
terep
(atx
, 10) = _HEIGHT(kep
(0)) - 1terep
(atx
, 11) = _WIDTH(kep
(0)) - 1terep
(atx
, 12) = _HEIGHT(kep
(0)) - 1terep
(atx
, 14) = 1:
REM terep aktiv