📄 svgabc25.txt
字号:
27
D3ROTATE
PROTOTYPE
SUB D3ROTATE (NumPoints%, X%, Y%, Z%, AngleZ%, AngleY%,
AngleX%, InArray%, OutArray%)
INPUT
NumPoints - number of points to be rotated
X, Y, Z - center of rotation
AngleZ - angle of rotation about the Z axis
AngleY - angle of rotation about the Y axis
AngleX - angle of rotation about the X axis
InArray - P3DType array containing points to rotate
OUTPUT
no value returned
OutArray - P3DType array holding rotated values
USAGE
D3ROTATE takes the three dimensional points given in InArray
and rotates them by the specified angles about Xorigin,
Yorigin, Zorigin. The results are returned in OutArray which
can be the same as InArray. A virtual set of axes are placed
at the origin of rotation and rotation takes place about these
axes. A positive angle causes a counter-clockwise rotation
from the positive X axis to the positive Y axis.
Arrays should be passed by giving the element within the array
from where the action should take place. This allows the
programmer to store more than one item within the same array
or act on only a portion of the array.
SEE ALSO
D3PROJECT, D3SCALE, D3TRANSLATE
EXAMPLE
REM ROTATE A CUBE AT THE CENTER OF THE SCREEN
REM $INCLUDE: 'SVGABC.BI'
DEFINT A-Z
DIM CUBE(1 TO 8) AS P3DType
DIM RCUBE(1 TO 8) AS P3DType
DIM PLOT(1 TO 8) AS P2DType
DIM PROJPARAMS AS PROJType
CUBE(1).X = 100 : CUBE(1).Y = -100 : CUBE(1).Z = 100
CUBE(2).X = 100 : CUBE(2).Y = -100 : CUBE(2).Z = -100
CUBE(3).X = 100 : CUBE(3).Y = 100 : CUBE(3).Z = -100
CUBE(4).X = 100 : CUBE(4).Y = 100 : CUBE(4).Z = 100
28
CUBE(5).X = -100 : CUBE(5).Y = -100 : CUBE(5).Z = 100
CUBE(6).X = -100 : CUBE(6).Y = -100 : CUBE(6).Z = -100
CUBE(7).X = -100 : CUBE(7).Y = 100 : CUBE(7).Z = -100
CUBE(8).X = -100 : CUBE(8).Y = 100 : CUBE(8).Z = 100
VMODE = VIDEOMODEGET
IF WHICHVGA = 0 THEN STOP
DUMMY=RES640
PROJPARAMS.EYEX = -1040
PROJPARAMS.EYEY = -600
PROJPARAMS.EYEZ = -1200
PROJPARAMS.SCRD = 1700
PROJPARAMS.THETA = 30
PROJPARAMS.PHI = 45
FOR I = 0 TO 360 STEP 5
D3ROTATE 8, 0, 0, 0, I, I, I, CUBE(1).X, RCUBE(1).X
DUMMY = D3PROJECT(8,PROJPARAMS.EYEX,RCUBE(1).X,PLOT(1).X)
GOSUB DRWCUBE
SDELAY 2
GOSUB DRWCUBE
NEXT I
WHILE INKEY$ = ""
WEND
VIDEOMODESET VMODE
END
DRWCUBE:
FOR J=1 TO 3
DRWLINE 2, 10, PLOT(J).X, PLOT(J).Y, PLOT(J+1).X, PLOT(J+1).Y
NEXT J
DRWLINE 2, 10, PLOT(4).X, PLOT(4).Y, PLOT(1).X, PLOT(1).Y
FOR J=5 TO 7
DRWLINE 2, 10, PLOT(J).X, PLOT(J).Y, PLOT(J+1).X, PLOT(J+1).Y
NEXT J
DRWLINE 2, 10, PLOT(8).X, PLOT(8).Y, PLOT(5).X, PLOT(5).Y
FOR J=1 TO 4
DRWLINE 2, 10, PLOT(J).X, PLOT(J).Y, PLOT(J+4).X, PLOT(J+4).Y
NEXT J
RETURN
29
D3SCALE
PROTOTYPE
SUB D3SCALE (NumPoints%, ScaleX%, ScaleY%, ScaleZ%, InArray%,
OutArray%)
INPUT
NumPoints - number of points to scale
ScaleX - scale factor along X axis
ScaleY - scale factor along Y axis
ScaleZ - scale factor along Z axis
InArray - P3DType array containing points to scale
OUTPUT
no value returned
OutArray - P3DType array holding scaled values
USAGE
D3SCALE multiplies each coordinate in the three dimensional
array InArray by the corresponding scale factor ScaleX, ScaleY
or ScaleZ. The results are stored in OutArray which can be
the same as InArray. A scale factor of 256 (100 hex) is
considered 100 percent and results in no change. Therefore,
128 (80 hex) reduces values by one half and 512 (200 hex)
doubles values.
Arrays should be passed by giving the element within the array
from where the action should take place. This allows the
programmer to store more than one item within the same array
or act on only a portion of the array.
SEE ALSO
D3PROJECT, D3ROTATE, D3TRANSLATE
EXAMPLE
REM SCALE A CUBE AT THE CENTER OF THE SCREEN
REM $INCLUDE: 'SVGABC.BI'
DEFINT A-Z
DIM CUBE(1 TO 8) AS P3DType
DIM SCUBE(1 TO 8) AS P3DType
DIM PLOT(1 TO 8) AS P2DType
DIM PROJPARAMS AS PROJType
CUBE(1).X = 100 : CUBE(1).Y = -100 : CUBE(1).Z = 100
CUBE(2).X = 100 : CUBE(2).Y = -100 : CUBE(2).Z = -100
CUBE(3).X = 100 : CUBE(3).Y = 100 : CUBE(3).Z = -100
CUBE(4).X = 100 : CUBE(4).Y = 100 : CUBE(4).Z = 100
CUBE(5).X = -100 : CUBE(5).Y = -100 : CUBE(5).Z = 100
30
CUBE(6).X = -100 : CUBE(6).Y = -100 : CUBE(6).Z = -100
CUBE(7).X = -100 : CUBE(7).Y = 100 : CUBE(7).Z = -100
CUBE(8).X = -100 : CUBE(8).Y = 100 : CUBE(8).Z = 100
VMODE = VIDEOMODEGET
IF WHICHVGA = 0 THEN STOP
DUMMY=RES640
PROJPARAMS.EYEX = -1040
PROJPARAMS.EYEY = -600
PROJPARAMS.EYEZ = -1200
PROJPARAMS.SCRD = 1700
PROJPARAMS.THETA = 30
PROJPARAMS.PHI = 45
FOR I = 256 TO 128 STEP -4
D3SCALE 8, I, I, I, CUBE(1).X, SCUBE(1).X
DUMMY = D3PROJECT(8,PROJPARAMS.EYEX,SCUBE(1).X,PLOT(1).X)
GOSUB DRWCUBE
SDELAY 2
GOSUB DRWCUBE
NEXT I
FOR I = 132 TO 256 STEP 4
D3SCALE 8, I, I, I, CUBE(1).X, SCUBE(1).X
DUMMY = D3PROJECT(8,PROJPARAMS.EYEX,SCUBE(1).X,PLOT(1).X)
GOSUB DRWCUBE
SDELAY 2
GOSUB DRWCUBE
NEXT I
WHILE INKEY$ = ""
WEND
VIDEOMODESET VMODE
END
DRWCUBE:
FOR J=1 TO 3
DRWLINE 2, 10, PLOT(J).X, PLOT(J).Y, PLOT(J+1).X, PLOT(J+1).Y
NEXT J
DRWLINE 2, 10, PLOT(4).X, PLOT(4).Y, PLOT(1).X, PLOT(1).Y
FOR J=5 TO 7
DRWLINE 2, 10, PLOT(J).X, PLOT(J).Y, PLOT(J+1).X, PLOT(J+1).Y
NEXT J
DRWLINE 2, 10, PLOT(8).X, PLOT(8).Y, PLOT(5).X, PLOT(5).Y
FOR J=1 TO 4
DRWLINE 2, 10, PLOT(J).X, PLOT(J).Y, PLOT(J+4).X, PLOT(J+4).Y
NEXT J
RETURN
31
D3TRANSLATE
PROTOTYPE
SUB D3TRANSLATE (NumPoints%, TransX%, TransY%, TransZ%,
InArray%, OutArray%)
INPUT
NumPoints - number of points to translate
TransX - distance to translate along X axis
TransY - distance to translate along Y axis
TransZ - distance to translate along Z axis
InArray - P3DType array containing points to translate
OUTPUT
no value returned
OutArray - P3DType array holding translated points
USAGE
D3TRANSLATE takes the three dimensional points given in
InArray and translates them by the specified number of pixels
along each axis. The results are returned in OutArray which
can be the same as InArray.
Arrays should be passed by giving the element within the array
from where the action should take place. This allows the
programmer to store more than one item within the same array
or act on only a portion of the array.
SEE ALSO
D3PROJECT, D3ROTATE, D3SCALE
EXAMPLE
REM TRANSLATE A CUBE NEAR THE CENTER OF THE SCREEN
REM $INCLUDE: 'SVGABC.BI'
DEFINT A-Z
DIM CUBE(1 TO 8) AS P3DType
DIM TCUBE(1 TO 8) AS P3DType
DIM PLOT(1 TO 8) AS P2DType
DIM PROJPARAMS AS PROJType
CUBE(1).X = 100 : CUBE(1).Y = -100 : CUBE(1).Z = 100
CUBE(2).X = 100 : CUBE(2).Y = -100 : CUBE(2).Z = -100
CUBE(3).X = 100 : CUBE(3).Y = 100 : CUBE(3).Z = -100
CUBE(4).X = 100 : CUBE(4).Y = 100 : CUBE(4).Z = 100
CUBE(5).X = -100 : CUBE(5).Y = -100 : CUBE(5).Z = 100
CUBE(6).X = -100 : CUBE(6).Y = -100 : CUBE(6).Z = -100
CUBE(7).X = -100 : CUBE(7).Y = 100 : CUBE(7).Z = -100
CUBE(8).X = -100 : CUBE(8).Y = 100 : CUBE(8).Z = 100
32
VMODE = VIDEOMODEGET
IF WHICHVGA = 0 THEN STOP
DUMMY=RES640
PROJPARAMS.EYEX = -1040
PROJPARAMS.EYEY = -600
PROJPARAMS.EYEZ = -1200
PROJPARAMS.SCRD = 1700
PROJPARAMS.THETA = 30
PROJPARAMS.PHI = 45
FOR I = 0 TO 100 STEP 2
D3TRANSLATE 8, I, I, I, CUBE(1).X, TCUBE(1).X
DUMMY = D3PROJECT(8,PROJPARAMS.EYEX,TCUBE(1).X,PLOT(1).X)
GOSUB DRWCUBE
SDELAY 2
GOSUB DRWCUBE
NEXT I
FOR I = 98 TO 0 STEP -2
D3TRANSLATE 8, I, I, I, CUBE(1).X, TCUBE(1).X
DUMMY = D3PROJECT(8,PROJPARAMS.EYEX,TCUBE(1).X,PLOT(1).X)
GOSUB DRWCUBE
SDELAY 2
GOSUB DRWCUBE
NEXT I
WHILE INKEY$ = ""
WEND
VIDEOMODESET VMODE
END
DRWCUBE:
FOR J=1 TO 3
DRWLINE 2, 10, PLOT(J).X, PLOT(J).Y, PLOT(J+1).X, PLOT(J+1).Y
NEXT J
DRWLINE 2, 10, PLOT(4).X, PLOT(4).Y, PLOT(1).X, PLOT(1).Y
FOR J=5 TO 7
DRWLINE 2, 10, PLOT(J).X, PLOT(J).Y, PLOT(J+1).X, PLOT(J+1).Y
NEXT J
DRWLINE 2, 10, PLOT(8).X, PLOT(8).Y, PLOT(5).X, PLOT(5).Y
FOR J=1 TO 4
DRWLINE 2, 10, PLOT(J).X, PLOT(J).Y, PLOT(J+4).X, PLOT(J+4).Y
NEXT J
RETURN
33
DRWALINE
PROTOTYPE
SUB DRWALINE (ColrBits%, Colr%, X1%, Y1%, X2%, Y2%)
INPUT
ColrBits - number of bits of color
Colr - index to color in current palette
X1, Y1 - location of one endpoint of line
X2, Y2 - location of other endpoint of line
OUTPUT
no value returned
USAGE
DRWALINE draws an antialiased line of the specified color
using with endpoints located at (X1, Y1) and (X2,Y2).
Antialiased lines trick the eye into seeing true vector lines
instead of a jagged series of individual pixels. This is
accomplished by drawing two pixels of the same color but with
different intensities (brightness) for each pixel drawn by
DRWALINE. The eye averages the pixels to see only a straight
line. Note that the palette must be set up with the correct
color entries for the line to look correct. All values of X1,
Y1, X2 and Y2 are valid. Any portion of the line that lies
outside of the currently defined viewport will not be drawn.
Colrbits should be a number in the range of 0 to 6 specifying
the number of
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -