Entry
BBCBASIC: Windows: Computer: Graphics: 3D: How to possibly create .raw file from triangles in DATA?
Feb 12th, 2006 13:29
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 12 February 2021 - 08:42 pm -------------------
BBCBASIC: Windows: Computer: Graphics: 3D: How to possibly create .raw
file from triangles in DATA?
---
Steps: Overview:
1. -Add your triangle data in the DATA
statements of your BBC program
2. -Run the BBC program
3. -That will spool the triangle data
9 coordinates at a time to a .raw
file
4. -The file will not contain color information
(because that information seems currently not to be possible to
store in a .raw
file)
5. -You can then load this .raw file
in e.g.
-CrossRoads
-Adobe Acrobat 3D Toolkit
-RheinGold 3DWin (convert)
to convert to other formats and or edit
===
Steps: Worked out:
1. -Add your triangle data in the DATA
statements of your BBC program
2. -Run the BBC program
e.g.
--- cut here: begin --------------------------------------------------
MODE 8
:
INSTALL @lib$ + "D3DLIB"
:
triangleTotalI% = 2 * ( 11 + 3 ) : REM total amount of triangles in
your figure
:
filename$ = "TRIANGLEN.B3D" : REM the file containing the data for
this triangles (in binary format)
:
filenameRaw$ = "c:\temp\trianglen.raw" : REM file containing the raw
file (to be loaded in e.g. Adobe Acrobat 3D Toolkit, CrossRoads,
RheinGold 3DWin, ...)
:
dataB% = TRUE : REM set to true if you want to generate the binary
output file containing the data (should only be done once the first
time)
:
dimB% = TRUE : REM set to true if you want to dimension arrays
(should only be done once the first time)
:
IF dataB% THEN PROCGraphicsViewTriangleDataN( triangleTotalI%,
filename$ )
:
IF dimB% THEN PROCGraphicsViewTriangleDimN( triangleTotalI% )
:
IF HIMEM < PAGE + 9999 THEN HIMEM = PAGE + 4200
:
ON CLOSE PROCcleanup : QUIT
:
ON ERROR PROCcleanup : PRINT REPORT$ : END
:
d% = FN_initd3d( @hwnd%, 1, 0 )
IF d% = 0 THEN ERROR 100, "Can not initialise Direct3D"
b%(0) = FN_load3d( d%, @dir$ + filename$, n%( 0 ), f%( 0 ), s%( 0 ) )
IF b%( 0 ) = 0 ERROR 100, "Can not load" + filename$
e() = 0, 0, -6
a() = 0, 0, 0
REPEAT
p() = TIME / 100
r() = TIME / 80
X() = SIN( TIME / 200 )
PROC_render( d%, &FF7F7F7F, 0, l%(), 2, m%(), t%(), b%(), n%(), f%
(), s%(), y(), p(), r(), X(), Y(), Z(), e(), a(), PI/4, 5/4, 1, 1000 )
UNTIL INKEY( 1 ) = 0
END
:
:
:
DEF PROCGraphicsViewTriangleDataN( triangleTotalI%, filename$ )
LOCAL F%
:
LOCAL triangleI%
LOCAL triangleMinI%
LOCAL triangleMaxI%
:
LOCAL pointI%
LOCAL pointMinI%
LOCAL pointMaxI%
:
LOCAL xR
LOCAL yR
LOCAL zR
LOCAL colorR
:
triangleMinI% = 1
triangleMaxI% = triangleTotalI%
pointMinI% = 1
pointMaxI% = 3
F% = OPENOUT filename$
OSCLI( "SPOOL" + " " + filenameRaw$ )
REM PRINT "N0"
PROC4( triangleTotalI% * 3 ) : REM for each triangle exactly 3
points, thus totally N . 3 points
PROC4( &100042 ) : REM vertex size &10 and format &42 (possibly
change this)
FOR triangleI% = triangleMinI% TO triangleMaxI%
FOR pointI% = pointMinI% TO pointMaxI%
READ xR, yR, zR, colorR
xR = xR / 9 : REM scale down
yR = yR / 9 : REM scale down
zR = zR / 9 : REM scale down
PRINT ; xR; " "; yR; " "; zR; " ";
PROC4( FN_f4( xR ) ) : PROC4( FN_f4( yR ) ) : PROC4( FN_f4(
zR ) ) : PROC4( colorR )
NEXT pointI%
PRINT
NEXT triangleI%
*SPOOL
CLOSE #F%
ENDPROC
:
DEF PROC4( A% )
BPUT# F%,A%
BPUT# F%, A% >> 8
BPUT# F%, A% >> 16
BPUT# F%, A% >> 24
ENDPROC
:
DEF PROCcleanup
t%(1) += 0 : IF t%(1) PROC_release(t%(1))
b%(0) += 0 : IF b%(0) PROC_release(b%(0))
b%(1) += 0 : IF b%(1) PROC_release(b%(1))
d% += 0 : IF d% PROC_release(d%)
ENDPROC
:
DEF PROCGraphicsViewTriangleDimN( triangleTotalI% )
DIM l%(0)
DIM b%(1)
DIM n%(10)
DIM f%(1)
DIM s%(1)
DIM m%(1)
DIM t%(1)
DIM y(1)
DIM p(1)
DIM r(1)
DIM X(1)
DIM Y(1)
DIM Z(1)
DIM e(2)
DIM a(2)
ENDPROC
:
REM put here your N triangles
:
REM The format is:
REM DATA <x of point 1>, <y of point 1>, <z of point 1>, <color of
point 1>
REM DATA <x of point 2>, <y of point 2>, <z of point 2>, <color of
point 2>
REM DATA <x of point 3>, <y of point 3>, <z of point 3>, <color of
point 3>
:
REM body: head: circumference: begin
:
REM triangle 001 (totally 3 points per triangle)
DATA 0.0, 0.0, 9.0, &FF0000FF
DATA -4.0, 0.0, 7.0, &FF00FF10
DATA -3.0, 0.0, 9.0, &FFFF0020
:
REM triangle 002 (totally 3 points per triangle)
DATA 0.0, 0.0, 9.0, &FFFF0030
DATA 3.0, 0.0, 9.0, &FFFF0040
DATA 4.0, 0.0, 7.0, &FFFF0050
:
REM triangle 003 (totally 3 points per triangle)
DATA 0.0, 0.0, 9.0, &FFFF0060
DATA -4.0, 0.0, 1.0, &FFFF0070
DATA -4.0, 0.0, 7.0, &FFFF0080
:
REM triangle 004 (totally 3 points per triangle)
DATA 0.0, 0.0, 9.0, &FFFF0090
DATA 4.0, 0.0, 7.0, &FFFF0100
DATA 4.0, 0.0, 1.0, &FFFF0110
:
REM triangle 005 (totally 3 points per triangle)
DATA 0.0, 0.0, 9.0, &FFFF0000
DATA -2.0, 0.0, 3.0, &FFFF0000
DATA -4.0, 0.0, 1.0, &FFFF0000
:
REM triangle 006 (totally 3 points per triangle)
DATA 0.0, 0.0, 9.0, &FFFF0000
DATA 4.0, 0.0, 1.0, &FFFF0000
DATA 2.0, 0.0, 3.0, &FFFF0000
:
REM triangle 007 (totally 3 points per triangle)
DATA 0.0, 0.0, 9.0, &FFFF0000
DATA -2.0, 0.0, 0.0, &FFFF0000
DATA -2.0, 0.0, 3.0, &FFFF0000
:
REM triangle 008 (totally 3 points per triangle)
DATA 0.0, 0.0, 9.0, &FFFF0000
DATA 2.0, 0.0, 3.0, &FFFF0000
DATA 2.0, 0.0, 0.0, &FFFF0000
:
REM triangle 009 (totally 3 points per triangle)
DATA 0.0, 0.0, 9.0, &FFFF0000
DATA 2.0, 0.0, 0.0, &FFFF0000
DATA -2.0, 0.0, 0.0, &FFFF0000
:
REM triangle 010 (totally 3 points per triangle)
DATA -4.0, 0.0, 1.0, &FFFF0000
DATA -2.0, 0.0, 3.0, &FFFF0000
DATA -2.0, 0.0, 1.0, &FFFF0000
:
REM triangle 011 (totally 3 points per triangle)
DATA 4.0, 0.0, 1.0, &FFFF0000
DATA 2.0, 0.0, 1.0, &FFFF0000
DATA 2.0, 0.0, 3.0, &FFFF0000
:
REM translated in y-direction
:
REM triangle 001 (totally 3 points per triangle)
DATA 0.0, 4.0, 9.0, &FF0000FF
DATA -4.0, 4.0, 7.0, &FF00FF10
DATA -3.0, 4.0, 9.0, &FFFF0020
:
REM triangle 002 (totally 3 points per triangle)
DATA 0.0, 4.0, 9.0, &FFFF0030
DATA 3.0, 4.0, 9.0, &FFFF0040
DATA 4.0, 4.0, 7.0, &FFFF0050
:
REM triangle 003 (totally 3 points per triangle)
DATA 0.0, 4.0, 9.0, &FFFF0060
DATA -4.0, 4.0, 1.0, &FFFF0070
DATA -4.0, 4.0, 7.0, &FFFF0080
:
REM triangle 004 (totally 3 points per triangle)
DATA 0.0, 4.0, 9.0, &FFFF0090
DATA 4.0, 4.0, 7.0, &FFFF0100
DATA 4.0, 4.0, 1.0, &FFFF0110
:
REM triangle 005 (totally 3 points per triangle)
DATA 0.0, 4.0, 9.0, &FFFF0000
DATA -2.0, 4.0, 3.0, &FFFF0000
DATA -4.0, 4.0, 1.0, &FFFF0000
:
REM triangle 006 (totally 3 points per triangle)
DATA 0.0, 4.0, 9.0, &FFFF0000
DATA 4.0, 4.0, 1.0, &FFFF0000
DATA 2.0, 4.0, 3.0, &FFFF0000
:
REM triangle 007 (totally 3 points per triangle)
DATA 0.0, 4.0, 9.0, &FFFF0000
DATA -2.0, 4.0, 0.0, &FFFF0000
DATA -2.0, 4.0, 3.0, &FFFF0000
:
REM triangle 008 (totally 3 points per triangle)
DATA 0.0, 4.0, 9.0, &FFFF0000
DATA 2.0, 4.0, 3.0, &FFFF0000
DATA 2.0, 4.0, 0.0, &FFFF0000
:
REM triangle 009 (totally 3 points per triangle)
DATA 0.0, 4.0, 9.0, &FFFF0000
DATA 2.0, 4.0, 0.0, &FFFF0000
DATA -2.0, 4.0, 0.0, &FFFF0000
:
REM triangle 010 (totally 3 points per triangle)
DATA -4.0, 4.0, 1.0, &FFFF0000
DATA -2.0, 4.0, 3.0, &FFFF0000
DATA -2.0, 4.0, 1.0, &FFFF0000
:
REM triangle 011 (totally 3 points per triangle)
DATA 4.0, 4.0, 1.0, &FFFF0000
DATA 2.0, 4.0, 1.0, &FFFF0000
DATA 2.0, 4.0, 3.0, &FFFF0000
:
REM body: head: circumference: end
:
REM body: head: chin: begin
:
REM triangle 01 (totally 3 points per triangle)
DATA 0.0, 0.0, 3.0, &FF0F0010
DATA -1.0, 0.0, 1.0, &FF0F0020
DATA -2.0, 0.0, 3.0, &FF0F0030
:
REM triangle 02 (totally 3 points per triangle)
DATA 0.0, 0.0, 3.0, &FF0F0040
DATA 1.0, 0.0, 1.0, &FF0F0050
DATA -1.0, 0.0, 1.0, &FF0F0060
:
REM triangle 03 (totally 3 points per triangle)
DATA 0.0, 0.0, 3.0, &FF0F0070
DATA 2.0, 0.0, 3.0, &FF0F0080
DATA 1.0, 0.0, 1.0, &FF0F0090
:
REM translated in y-direction
:
REM triangle 01 (totally 3 points per triangle)
DATA 0.0, 1.0, 3.0, &FF0F0010
DATA -1.0, 1.0, 1.0, &FF0F0020
DATA -2.0, 1.0, 3.0, &FF0F0030
:
REM triangle 02 (totally 3 points per triangle)
DATA 0.0, 1.0, 3.0, &FF0F0040
DATA 1.0, 1.0, 1.0, &FF0F0050
DATA -1.0, 1.0, 1.0, &FF0F0060
:
REM triangle 03 (totally 3 points per triangle)
DATA 0.0, 1.0, 3.0, &FF0F0070
DATA 2.0, 1.0, 3.0, &FF0F0080
DATA 1.0, 1.0, 1.0, &FF0F0090
:
REM body: head: chin: begin
:
--- cut here: end ----------------------------------------------------
3. -That will spool the triangle data
9 coordinates at a time to a .raw
file
--- cut here: begin --------------------------------------------------
0 0 1 -0.44 0 0.78 -0.33 0 1
0 0 1 0.33 0 1 0.44 0 0.78
0 0 1 -0.44 0 0.11 -0.44 0 0.78
0 0 1 0.44 0 0.78 0.44 0 0.11
0 0 1 -0.22 0 0.33 -0.44 0 0.11
0 0 1 0.44 0 0.11 0.22 0 0.33
0 0 1 -0.22 0 0 -0.22 0 0.33
0 0 1 0.22 0 0.33 0.22 0 0
0 0 1 0.22 0 0 -0.22 0 0
-0.44 0 0.11 -0.22 0 0.33 -0.22 0 0.11
0.44 0 0.11 0.22 0 0.11 0.22 0 0.33
0 0.44 1 -0.44 0.44 0.78 -0.33 0.44 1
0 0.44 1 0.33 0.44 1 0.44 0.44 0.78
0 0.44 1 -0.44 0.44 0.11 -0.44 0.44 0.78
0 0.44 1 0.44 0.44 0.78 0.44 0.44 0.11
0 0.44 1 -0.22 0.44 0.33 -0.44 0.44 0.11
0 0.44 1 0.44 0.44 0.11 0.22 0.44 0.33
0 0.44 1 -0.22 0.44 0 -0.22 0.44 0.33
0 0.44 1 0.22 0.44 0.33 0.22 0.44 0
0 0.44 1 0.22 0.44 0 -0.22 0.44 0
-0.44 0.44 0.11 -0.22 0.44 0.33 -0.22 0.44 0.11
0.44 0.44 0.11 0.22 0.44 0.11 0.22 0.44 0.33
0 0 0.33 -0.11 0 0.11 -0.22 0 0.33
0 0 0.33 0.11 0 0.11 -0.11 0 0.11
0 0 0.33 0.22 0 0.33 0.11 0 0.11
0 0.11 0.33 -0.11 0.11 0.11 -0.22 0.11 0.33
0 0.11 0.33 0.11 0.11 0.11 -0.11 0.11 0.11
--- cut here: end ----------------------------------------------------
4. -The file will not contain color information
(because that information seems currently not to be possible to
store in a .raw
file)
5. -You can then load this .raw file
in e.g.
-CrossRoads
-Adobe Acrobat 3D Toolkit
-RheinGold 3DWin (convert)
to convert to other formats and or edit
---
---
Internet: see also:
---
BBCBASIC: Windows: Graphics: Microsoft: DirectX: Link: Overview: Can
you give an overview of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/39482/fid/768
----------------------------------------------------------------------