WRLファイルを作る
ご注意
別途プラグイン等必要です。 (VRML,プラグイン等で検索してください)
LET N=51 LET XS=-5 LET XE=5 LET YS=-5 LET YE=5 LET ZS=-5 LET ZE=5 LET MODE=0 INPUT PROMPT "SAVE FILENAME(.WRL)=":F$ IF POS(F$,".")=0 THEN LET F$=F$ & ".WRL" OPEN #1:NAME F$ PRINT #1:"#VRML V2.0 utf8" !'ヘッダー部はコピペ PRINT #1:"NavigationInfo {" PRINT #1:" headlight TRUE" PRINT #1:" type [";CHR$(34);"EXAMINE";CHR$(34);" ";CHR$(34);"ANY";CHR$(34);"]" PRINT #1:"}" PRINT #1:"Background {" PRINT #1:" skyColor [1 1 1]" PRINT #1:"}" PRINT #1:"Viewpoint {" PRINT #1:" position 0 0 15" PRINT #1:"}" PRINT #1:"Shape {" PRINT #1:" appearance Appearance {" PRINT #1:" material Material {" PRINT #1:" }" PRINT #1:" }" PRINT #1:" geometry IndexedFaceSet {" PRINT #1:" solid FALSE" PRINT #1:" colorPerVertex FALSE" PRINT #1:" coord Coordinate {" PRINT #1:" point [" FOR J=0 TO N-1 LET Z=ZS+(ZE-ZS)/(N-1)*J FOR I=0 TO N-1 LET X=XS+(XE-XS)/(N-1)*I LET Y=FUNC(MODE,X,Z) LET Y=MIN(YE,MAX(Y,YS)) PRINT #1:" ";FORM$(X);" ";FORM$(Y);" ";FORM$(Z); IF I=N-1 AND J=N-1 THEN PRINT #1 ELSE PRINT #1:"," NEXT I NEXT J PRINT #1:" ]" PRINT #1:" }" PRINT #1:" color Color {" !'コピペ PRINT #1:" color [1 0.73 0.73, 1 0.87 0.73, 1 1 0.73, 0.87 1 0.73]" PRINT #1:" }" PRINT #1:" coordIndex [" FOR I=0 TO N-2 FOR J=0 TO N-2 PRINT #1:STR$(J+N*I);" ";STR$(J+1+N*I);" ";STR$(J+1+N*(I+1));" ";STR$(J+N*(I+1));" -1" NEXT J NEXT I PRINT #1:" ]" PRINT #1:" colorIndex [" FOR I=1 TO N^2 PRINT #1:" 2" NEXT I PRINT #1:" ]" PRINT #1:" }" PRINT #1:"}" CLOSE #1 END
EXTERNAL FUNCTION FUNC(MODE,X,Y) SELECT CASE MODE CASE 0 LET FUNC=COS(5*SQR(X*X+Y*Y)) CASE 1 LET FUNC=X*Y*(X^2-Y^2) CASE 2 LET FUNC=(X^2-Y^2)/2 CASE 3 LET FUNC=EXP(-X^2-Y^2)*(X^2+Y^2) CASE 4 IF (X^2-1)*(X^2-9)*(Y^2-1)*(Y^2-9)>0 THEN LET FUNC=2 ELSE LET FUNC=0 END IF CASE 5 LET Z=4-X^2-Y^2 IF Z>0 THEN LET FUNC=SQR(Z) ELSE LET FUNC=0 END SELECT END FUNCTION
EXTERNAL FUNCTION FORM$(X) FORM$=LTRIM$(USING$("---%.######",X)) END FUNCTION
|