Entry
BBCBASIC: Windows: Graphics: Microsoft:DirectX: Create: Figure: Triangle: 1: How to view 1 triangle?
Feb 4th, 2006 12:50
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 04 February 2021 - 07:49 pm -------------------
BBCBASIC: Windows: Graphics: Microsoft:DirectX: Create: Figure:
Triangle: 1: How to view 1 triangle?
---
You create 2 files,
one containing the points of your triangles,
and one showing this content.
===
Steps: Overview:
1. -Create a file with the vertices of your figure
1. -This can by design only be triangles
x
x x
1. -So you must describe your figures' vertices
using a concatenation of triangles only
1. -You call this 'triangulation')
2. -For first to last triangle of your figure
1. -For each of the 3 points of that triangle
1. -Write the x-coordinate of that triangle to a file
2. -Write the y-coordinate of that triangle to a file
3. -Write the z-coordinate of that triangle to a file
4. -Write the reflection color at that point to a file
3. -Endfor
2. -Use the render file
1. -Make sure that both files (your file containing the points of
your figure and the render file) are in the same directory, or
other wise adapt the path to your triangle source file
3. -Run the render file
===
Steps: Worked out:
1. -Create a file with the vertices of your figure
--- cut here: begin --------------------------------------------------
REM first create the file containing the N vertices of your wireframe
INSTALL @lib$+"D3DLIB"
F% = OPENOUT"TRIANGLE.B3D"
PROC4( 3 ) : REM 3 vertices in the format (x, y, z), thus here ( (-1,
0, 0), (1, -1, 0), (0, 1, 0) )
PROC4( &100042 ) : REM vertex size &10 and format &42
REM The 3 points of triangle 1
REM X Y
Z COLOR
PROC4( FN_f4( -1.0 ) ) : PROC4( FN_f4( -1.0 ) ) : PROC4( FN_f4(
1.0 ) ) : PROC4( &FF0000FF )
PROC4( FN_f4( 1.0 ) ) : PROC4( FN_f4( -1.0 ) ) : PROC4( FN_f4(
1.0 ) ) : PROC4( &FF00FF00 )
PROC4( FN_f4( 0.0 ) ) : PROC4( FN_f4( 1.0 ) ) : PROC4( FN_f4(
0.0 ) ) : PROC4( &FFFF0000 )
CLOSE #F%
END
:
DEF PROC4( A% )
BPUT#F%,A%
BPUT#F%,A%>>8
BPUT#F%,A%>>16
BPUT#F%,A%>>24
ENDPROC
--- cut here: end ----------------------------------------------------
2. -Run this file
3. -Create the render file
--- cut here: begin --------------------------------------------------
REM. Program to demonstrate use of Direct3D in BBC BASIC for Windows
MODE 8
DIM l%(0)
DIM b%(1)
DIM n%(1)
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)
IF HIMEM < PAGE + 9999 THEN HIMEM = PAGE + 4200
INSTALL @lib$+"D3DLIB"
ON CLOSE PROCcleanup : QUIT
ON ERROR PROCcleanup : PRINT REPORT$ : END
d% = FN_initd3d( @hwnd%, 1, 0 )
IF d% = 0 THEN ERROR 100, "Can't initialise Direct3D"
b%(0) = FN_load3d( d%, @dir$ + "TRIANGLE.B3D", n%( 0 ), f%( 0 ), s%(
0 ) )
IF b%( 0 ) = 0 ERROR 100, "Can't load TRIANGLE.B3D"
e() = 0, 0, -6
a() = 0, 0, 0
REPEAT
p() = TIME/100
r() = TIME/40
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 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
:
--- cut here: end ----------------------------------------------------
4. -Run this render file
5. -That will show a rotating 3D triangle
===
File: see also:
[file: 'pyramid.bbc' in the 'BBC BASIC for Windows' directory]
===
Help: see also:
[help: search for 'DirectX']
===
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
----------------------------------------------------------------------