1 ' by Svjatoslav Agejenko
\r
2 ' homeage: http://svjatoslav.eu
\r
3 ' e-mail: svjatoslav@svjatoslav.eu
\r
5 ' Before running, make sure include path is correct. See below.
\r
7 DECLARE SUB parsel (a$)
\r
8 DECLARE SUB stat2 (b!)
\r
10 DECLARE SUB getchc (a$, b!)
\r
11 DECLARE SUB start ()
\r
13 DECLARE SUB flushpoly (a!)
\r
14 DECLARE SUB usemtl (a$)
\r
15 DECLARE SUB flushp ()
\r
16 DECLARE SUB parse (a$)
\r
17 DECLARE SUB geth (b!)
\r
18 DECLARE SUB cmd (a$)
\r
19 DECLARE SUB getson (a$)
\r
20 DIM SHARED px(1 TO 1000)
\r
21 DIM SHARED py(1 TO 1000)
\r
22 DIM SHARED pz(1 TO 1000)
\r
27 DIM SHARED fil(1 TO 100)
\r
29 DIM SHARED sona$(1 TO 20)
\r
33 DIM SHARED mtl$(1 TO 50)
\r
34 DIM SHARED mtlp1(1 TO 50, 1 TO 100)
\r
35 DIM SHARED mtlp2(1 TO 50, 1 TO 100)
\r
36 DIM SHARED mtlp3(1 TO 50, 1 TO 100)
\r
37 DIM SHARED mtlp4(1 TO 50, 1 TO 100)
\r
38 DIM SHARED mtll(1 TO 50)
\r
41 DIM SHARED stkf(1 TO 500)
\r
42 DIM SHARED stks(1 TO 500)
\r
43 DIM SHARED stkp, fc, ipath$
\r
45 DIM SHARED chc$(1 TO 10, 1 TO 500)
\r
46 DIM SHARED chcl(1 TO 10)
\r
47 DIM SHARED chcf$(1 TO 10)
\r
48 DIM SHARED chct(1 TO 10)
\r
53 DIM SHARED var$(0 TO 100)
\r
54 DIM SHARED flag(1 TO 50, 0 TO 9)
\r
55 DIM SHARED cstatt, cstatm
\r
58 ipath$ = "c:\3dgen\include\" ' include path
\r
64 IF COMMAND$ = "" THEN END
\r
67 cmd "obj ~" + COMMAND$
\r
77 IF LEFT$(a$, 1) = "?" THEN
\r
78 IF flag(mtmprs, VAL(RIGHT$(LEFT$(a$, 2), 1))) = 1 THEN a$ = RIGHT$(a$, LEN(a$) - 3) ELSE GOTO 10
\r
81 SELECT CASE sona$(1)
\r
84 PRINT "terminated from file"
\r
100 FOR b = stkp TO 1 STEP -1
\r
101 SELECT CASE stkf(b)
\r
103 c1 = SIN(stks(b) / fc)
\r
104 s1 = COS(stks(b) / fc)
\r
105 z1 = x * c1 + z * s1
\r
106 x1 = x * s1 - z * c1
\r
111 c1 = SIN(stks(b) / fc)
\r
112 s1 = COS(stks(b) / fc)
\r
113 z1 = y * c1 + z * s1
\r
114 y1 = y * s1 - z * c1
\r
119 s1 = SIN(stks(b) / fc)
\r
120 c1 = COS(stks(b) / fc)
\r
121 y1 = y * c1 + x * s1
\r
122 x1 = y * s1 - x * c1
\r
150 IF nump > 900 THEN flushp
\r
159 b = INT(RND * (mitus - 1)) + 2
\r
163 IF mtll(cmtl) > 90 THEN flushpoly cmtl
\r
167 mtlp1(cmtl, b) = VAL(sona$(2)) + numpo
\r
168 mtlp2(cmtl, b) = VAL(sona$(3)) + numpo
\r
169 mtlp3(cmtl, b) = VAL(sona$(4)) + numpo
\r
170 IF sona$(5) = "" THEN mtlp4(cmtl, b) = -32000 ELSE mtlp4(cmtl, b) = VAL(sona$(5)) + numpo
\r
174 FOR a = mitus TO 3 STEP -1
\r
175 b$ = LEFT$(sona$(a), 2)
\r
176 c = VAL(RIGHT$(sona$(a), LEN(sona$(a)) - 2))
\r
208 mtmprs = mtmprs + 1
\r
209 cstatt = cstatt + 1
\r
210 LOCATE 10 + mtmprs, 1
\r
217 IF chcf$(b) <> a$ THEN getchc a$, b
\r
219 IF c <= chcl(b) THEN GOTO 2
\r
221 IF tmr > 20 THEN tmr = 0: stat
\r
222 LOCATE 10 + mtmprs, 1
\r
223 PRINT SPACE$(LEN(a$))
\r
224 mtmprs = mtmprs - 1
\r
232 OPEN sona$(2) + ".obj" FOR OUTPUT AS #res
\r
233 PRINT #res, "mtllib result.mtl"
\r
236 b = INT(RND * (mitus - 1)) + 2
\r
239 FOR d = 1 TO LEN(c$)
\r
240 e$ = RIGHT$(LEFT$(c$, d), 1)
\r
241 IF e$ = "^" THEN e$ = " "
\r
247 var$(VAL(sona$(2))) = sona$(3)
\r
250 IF sona$(3) = sona$(4) THEN b = 1 ELSE b = 0
\r
251 flag(mtmprs, VAL(sona$(2))) = b
\r
260 PRINT #res, "v " + STR$(px(a)) + " " + STR$(py(a)) + " " + STR$(-pz(a))
\r
267 IF mtll(a) = 0 THEN GOTO 5
\r
269 PRINT #res, "usemtl " + mtl$(a)
\r
270 FOR b = 1 TO mtll(a)
\r
271 c$ = "f " + STR$(mtlp1(a, b) + 1) + STR$(mtlp2(a, b) + 1) + STR$(mtlp3(a, b) + 1)
\r
272 IF mtlp4(a, b) <> -32000 THEN c$ = c$ + STR$(mtlp4(a, b) + 1)
\r
281 'DIM SHARED cstatt, cstatm
\r
283 IF chcf$(c) = a$ THEN b = c: GOTO 6
\r
288 IF chct(c) < d THEN d = chct(c): e = c
\r
292 'PRINT "file " + a$ + " loaded"
\r
293 cstatm = cstatm + 1
\r
295 IF LEFT$(b$, 1) = "~" THEN b$ = RIGHT$(b$, LEN(b$) - 1) ELSE b$ = ipath$ + b$
\r
296 OPEN b$ + ".3d" FOR INPUT AS #f
\r
298 IF EOF(f) <> 0 THEN GOTO 7
\r
300 IF (LEFT$(c$, 1) <> "#") AND (c$ <> SPACE$(LEN(c$))) THEN g = g + 1: chc$(e, g) = c$
\r
310 chctim = chctim + 1
\r
313 IF chctim > 10000 THEN
\r
315 chct(c) = chct(c) / 2
\r
317 chctim = chctim / 2
\r
324 IF fil(a) = 0 THEN fil(a) = 1: b = a: GOTO 1
\r
327 'PRINT "handle ", b, " allocated"
\r
340 FOR c = 1 TO LEN(b$)
\r
341 d$ = RIGHT$(LEFT$(b$, c), 1)
\r
342 IF d$ = " " OR d$ = CHR$(9) THEN
\r
345 IF e = 1 THEN mitus = mitus + 1
\r
346 sona$(mitus) = sona$(mitus) + d$
\r
352 IF LEFT$(sona$(c), 1) = "%" THEN
\r
353 sona$(c) = var$(VAL(RIGHT$(sona$(c), LEN(sona$(c)) - 1)))
\r
401 fc = 180 / 3.141285
\r
411 PRINT a, chcf$(a), chct(a), chcl(a)
\r
415 PRINT cstatt; "parsed"
\r
417 PRINT cstatm; "chache miss"
\r
419 PRINT INT(cstatm / cstatt * 100); "% chache miss "
\r
427 FOR a = 1 TO chcl(b)
\r
436 IF mtl$(b) = a$ THEN cmtl = b: GOTO 4
\r