/[cvs]/rabit/RaBit's Rapid Racers/Module_Geometry.bas
ViewVC logotype

Annotation of /rabit/RaBit's Rapid Racers/Module_Geometry.bas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Tue Mar 12 21:23:07 2002 UTC (22 years, 9 months ago) by cvsrabit
Branch: NFO, MAIN
CVS Tags: v034a, HEAD
Changes since 1.1: +0 -0 lines
Initial project import

1 cvsrabit 1.1 Attribute VB_Name = "Module_Geometry"
2     Global gCol_Geo_IbIndexBuffers As New Collection
3     Global gCol_Geo_lColours As New Collection
4     'Global gCol_Geo_LvVertexLists As New Collection
5     'Global gCol_Geo_IIndexLists As New Collection
6     '
7    
8     Public Sub InitialiseGeometry()
9    
10     '//0. Any Variables
11    
12     '//1. Define the colours at each corner
13     Const Corner000 As Long = &HFF0000 'red 0
14     Const Corner001 As Long = &HFF00 'green 1
15     Const Corner010 As Long = &HFF 'blue 2
16     Const Corner011 As Long = &HFF00FF 'magenta 3
17     Const Corner100 As Long = &HFFFF00 'yellow 4
18     Const Corner101 As Long = &HFFFF 'cyan 5
19     Const Corner110 As Long = &HFF8000 'orange 6
20     Const Corner111 As Long = &HFFFFFF 'white 7
21    
22     '//2. Define the faces
23    
24     'top
25     CubeVerts(0) = CreateLitVertex(-1, 1, -1, Corner010, 0, 0, 0)
26     CubeVerts(1) = CreateLitVertex(1, 1, -1, Corner110, 0, 0, 0)
27     CubeVerts(2) = CreateLitVertex(-1, 1, 1, Corner011, 0, 0, 0)
28    
29     CubeVerts(3) = CreateLitVertex(1, 1, -1, Corner110, 0, 0, 0)
30     CubeVerts(4) = CreateLitVertex(1, 1, 1, Corner111, 0, 0, 0)
31     CubeVerts(5) = CreateLitVertex(-1, 1, 1, Corner011, 0, 0, 0)
32    
33     'bottom
34     CubeVerts(6) = CreateLitVertex(-1, -1, -1, Corner000, 0, 0, 0)
35     CubeVerts(7) = CreateLitVertex(1, -1, -1, Corner100, 0, 0, 0)
36     CubeVerts(8) = CreateLitVertex(-1, -1, 1, Corner001, 0, 0, 0)
37    
38     CubeVerts(9) = CreateLitVertex(1, -1, -1, Corner100, 0, 0, 0)
39     CubeVerts(10) = CreateLitVertex(1, -1, 1, Corner101, 0, 0, 0)
40     CubeVerts(11) = CreateLitVertex(-1, -1, 1, Corner001, 0, 0, 0)
41    
42     'left
43     CubeVerts(12) = CreateLitVertex(-1, 1, -1, Corner010, 0, 0, 0)
44     CubeVerts(13) = CreateLitVertex(-1, 1, 1, Corner011, 0, 0, 0)
45     CubeVerts(14) = CreateLitVertex(-1, -1, -1, Corner000, 0, 0, 0)
46    
47     CubeVerts(15) = CreateLitVertex(-1, 1, 1, Corner011, 0, 0, 0)
48     CubeVerts(16) = CreateLitVertex(-1, -1, 1, Corner001, 0, 0, 0)
49     CubeVerts(17) = CreateLitVertex(-1, -1, -1, Corner000, 0, 0, 0)
50    
51     'right
52     CubeVerts(18) = CreateLitVertex(1, 1, -1, Corner110, 0, 0, 0)
53     CubeVerts(19) = CreateLitVertex(1, 1, 1, Corner111, 0, 0, 0)
54     CubeVerts(20) = CreateLitVertex(1, -1, -1, Corner100, 0, 0, 0)
55    
56     CubeVerts(21) = CreateLitVertex(1, 1, 1, Corner111, 0, 0, 0)
57     CubeVerts(22) = CreateLitVertex(1, -1, 1, Corner101, 0, 0, 0)
58     CubeVerts(23) = CreateLitVertex(1, -1, -1, Corner100, 0, 0, 0)
59    
60     'front
61     CubeVerts(24) = CreateLitVertex(-1, 1, 1, Corner011, 0, 0, 0)
62     CubeVerts(25) = CreateLitVertex(1, 1, 1, Corner111, 0, 0, 0)
63     CubeVerts(26) = CreateLitVertex(-1, -1, 1, Corner001, 0, 0, 0)
64    
65     CubeVerts(27) = CreateLitVertex(1, 1, 1, Corner111, 0, 0, 0)
66     CubeVerts(28) = CreateLitVertex(1, -1, 1, Corner101, 0, 0, 0)
67     CubeVerts(29) = CreateLitVertex(-1, -1, 1, Corner001, 0, 0, 0)
68    
69     'back
70     CubeVerts(30) = CreateLitVertex(-1, 1, -1, Corner010, 0, 0, 0)
71     CubeVerts(31) = CreateLitVertex(1, 1, -1, Corner110, 0, 0, 0)
72     CubeVerts(32) = CreateLitVertex(-1, -1, -1, Corner000, 0, 0, 0)
73    
74     CubeVerts(33) = CreateLitVertex(1, 1, -1, Corner110, 0, 0, 0)
75     CubeVerts(34) = CreateLitVertex(1, -1, -1, Corner100, 0, 0, 0)
76     CubeVerts(35) = CreateLitVertex(-1, -1, -1, Corner000, 0, 0, 0)
77    
78     '//Setup the Vertex buffer
79     Set vbCube = D3DDevice.CreateVertexBuffer(Len(CubeVerts(0)) * 36, 0, FVF_LVERTEX, D3DPOOL_MANAGED)
80    
81     If vbCube Is Nothing Then Debug.Print "ERROR: Could not create vertex buffer": Exit Sub
82    
83     D3DVertexBuffer8SetData vbCube, 0, Len(CubeVerts(0)) * 36, 0, CubeVerts(0)
84    
85     '//Setup the Vertex buffer for the indices version...
86     vList(0) = CreateLitVertex(-1, -1, -1, &HFFFFFF, 0, 0, 0)
87     vList(1) = CreateLitVertex(-1, -1, 1, &HFF0000, 0, 0, 0)
88     vList(2) = CreateLitVertex(-1, 1, -1, &HFF00, 0.5, 0, 0)
89     vList(3) = CreateLitVertex(-1, 1, 1, &HFF, 0.5, 0, 0)
90     vList(4) = CreateLitVertex(1, -1, -1, &HFF00FF, 0, 0, 0)
91     vList(5) = CreateLitVertex(1, -1, 1, &HFFFF00, 0, 0, 0)
92     vList(6) = CreateLitVertex(1, 1, -1, &HFFFF, 0.5, 0, 0)
93     vList(7) = CreateLitVertex(1, 1, 1, &HFF8000, 0.5, 0, 0)
94    
95     Set vbCubeIdx = D3DDevice.CreateVertexBuffer(Len(vList(0)) * 8, 0, FVF_LVERTEX, D3DPOOL_MANAGED)
96    
97     If vbCubeIdx Is Nothing Then Debug.Print "ERROR: Could not create vbCubeIdx": Exit Sub
98    
99     D3DVertexBuffer8SetData vbCubeIdx, 0, Len(vList(0)) * 8, 0, vList(0)
100    
101     '//Setup the index list.
102     'top
103     iList(0) = 2: iList(1) = 6: iList(2) = 3
104     iList(3) = 6: iList(4) = 7: iList(5) = 3
105    
106     'bottom
107     iList(6) = 0: iList(7) = 4: iList(8) = 1
108     iList(9) = 4: iList(10) = 5: iList(11) = 1
109    
110     'left
111     iList(12) = 2: iList(13) = 3: iList(14) = 0
112     iList(15) = 3: iList(16) = 1: iList(17) = 0
113    
114     'right
115     iList(18) = 6: iList(19) = 7: iList(20) = 4
116     iList(21) = 7: iList(22) = 5: iList(23) = 4
117    
118     'front
119     iList(24) = 3: iList(25) = 7: iList(26) = 1
120     iList(27) = 7: iList(28) = 5: iList(29) = 1
121    
122     'back
123     iList(30) = 2: iList(31) = 6: iList(32) = 0
124     iList(33) = 6: iList(34) = 4: iList(35) = 0
125    
126     '//Create the index buffer
127     Set ibCube = D3DDevice.CreateIndexBuffer(Len(iList(0)) * 36, 0, D3DFMT_INDEX16, D3DPOOL_MANAGED)
128    
129     If ibCube Is Nothing Then Debug.Print "ERROR: Could not create the index buffer": Exit Sub
130    
131     D3DIndexBuffer8SetData ibCube, 0, Len(iList(0)) * 36, 0, iList(0)
132    
133     '//A simple example of checking how many indices there are:
134     'D3DFMT_INDEX16 = 101
135     'D3DFMT_INDEX32 = 102
136     Dim ibDesc As D3DINDEXBUFFER_DESC
137     Dim IndexCount As Long 'how many indices are in the buffer
138    
139     ibCube.GetDesc ibDesc
140     'ibDesc.Pool
141     If ibDesc.Format = 101 Then
142    
143     '16 bit indices
144     IndexCount = ibDesc.Size / 2
145    
146     ElseIf ibDesc.Format = 102 Then
147    
148     '32 bit indices
149     IndexCount = ibDesc.Size / 4
150    
151     Else
152    
153     'no idea whats stored here!
154    
155     End If
156    
157     Debug.Print IndexCount, " indices in the buffer."
158    
159     '//A simple example of checking how many vertices there are:
160     Dim vbDesc As D3DVERTEXBUFFER_DESC
161     Dim DummyVertex As LITVERTEX
162     Dim VertexCount As Long
163     Dim TotalDivider As Long 'the size of the vertex structure
164    
165     vbCube.GetDesc vbDesc
166    
167     If vbDesc.FVF = FVF_LVERTEX Then
168    
169     'The type stored is the LVertex type
170     VertexCount = vbDesc.Size / Len(DummyVertex)
171    
172     Else
173    
174     'it's some other type of vertex, lets find out:
175     If Not (vbDesc.FVF And D3DFVF_XYZ) = 0 Then
176    
177     Debug.Print "D3DFVF_XYZ"
178     TotalDivider = TotalDivider + 12
179    
180     End If
181    
182     If Not (vbDesc.FVF And D3DFVF_XYZRHW) = 0 Then
183    
184     Debug.Print "D3DFVF_XYZRHW"
185     TotalDivider = TotalDivider + 16
186    
187     End If
188    
189     If Not (vbDesc.FVF And D3DFVF_NORMAL) = 0 Then
190    
191     Debug.Print "D3DFVF_NORMAL"
192     TotalDivider = TotalDivider + 12
193    
194     End If
195    
196     If Not (vbDesc.FVF And D3DFVF_DIFFUSE) = 0 Then
197    
198     Debug.Print "D3DFVF_DIFFUSE"
199     TotalDivider = TotalDivider + 4
200    
201     End If
202    
203     If Not (vbDesc.FVF And D3DFVF_SPECULAR) = 0 Then
204    
205     Debug.Print "D3DFVF_SPECULAR"
206     TotalDivider = TotalDivider + 4
207    
208     End If
209    
210     If Not (vbDesc.FVF And D3DFVF_TEX1) = 0 Then
211    
212     Debug.Print "D3DFVF_TEX1"
213     TotalDivider = TotalDivider + 8
214    
215     End If
216    
217     If Not (vbDesc.FVF And D3DFVF_TEX2) = 0 Then
218    
219     Debug.Print "D3DFVF_TEX2"
220     TotalDivider = TotalDivider + 8
221    
222     End If
223    
224     VertexCount = vbDesc.Size / TotalDivider
225    
226     End If
227    
228     ' Debug.Print VertexCount, " Vertices in the buffer"
229    
230     End Sub
231    

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed