1 |
cvsrabit |
1.1 |
Attribute VB_Name = "Module_Main" |
2 |
|
|
Option Explicit |
3 |
|
|
' |
4 |
|
|
|
5 |
|
|
Public Function CreateLitVertex(X As Single, Y As Single, Z As Single, Colour As Long, Specular As Long, tU As Single, tV As Single) As LITVERTEX |
6 |
|
|
|
7 |
|
|
With CreateLitVertex |
8 |
|
|
|
9 |
|
|
.X = X |
10 |
|
|
.Y = Y |
11 |
|
|
.Z = Z |
12 |
|
|
.Color = Colour |
13 |
|
|
.Specular = Specular |
14 |
|
|
.tU = tU |
15 |
|
|
.tV = tV |
16 |
|
|
|
17 |
|
|
End With |
18 |
|
|
|
19 |
|
|
End Function |
20 |
|
|
|
21 |
|
|
Public Function MakeVector(X As Single, Y As Single, Z As Single) As D3DVECTOR |
22 |
|
|
|
23 |
|
|
With MakeVector |
24 |
|
|
|
25 |
|
|
.X = X |
26 |
|
|
.Y = Y |
27 |
|
|
.Z = Z |
28 |
|
|
|
29 |
|
|
End With |
30 |
|
|
|
31 |
|
|
End Function |
32 |
|
|
|
33 |
|
|
Public Sub Main() |
34 |
|
|
|
35 |
|
|
Form_Start.Show |
36 |
|
|
Load Form_Debug |
37 |
|
|
|
38 |
|
|
End Sub |
39 |
|
|
|
40 |
|
|
Public Function GetNormal(v0 As D3DVECTOR, v1 As D3DVECTOR, v2 As D3DVECTOR) As D3DVECTOR |
41 |
|
|
|
42 |
|
|
Dim v01 As D3DVECTOR, v02 As D3DVECTOR, vNorm As D3DVECTOR |
43 |
|
|
|
44 |
|
|
'1. Get the vectors 0->1 and 0->2 |
45 |
|
|
D3DXVec3Subtract v01, v1, v0 |
46 |
|
|
D3DXVec3Subtract v02, v2, v0 |
47 |
|
|
|
48 |
|
|
'2. Get the cross product |
49 |
|
|
D3DXVec3Cross vNorm, v01, v02 |
50 |
|
|
|
51 |
|
|
'3. Normalize this vector |
52 |
|
|
D3DXVec3Normalize vNorm, vNorm |
53 |
|
|
|
54 |
|
|
'4. Return the value: |
55 |
|
|
GetNormal = vNorm |
56 |
|
|
|
57 |
|
|
End Function |
58 |
|
|
|
59 |
|
|
Public Function CreateD3DColorVal(A As Single, R As Single, G As Single, B As Single) As D3DCOLORVALUE |
60 |
|
|
|
61 |
|
|
With CreateD3DColorVal |
62 |
|
|
|
63 |
|
|
.A = A |
64 |
|
|
.R = R |
65 |
|
|
.G = G |
66 |
|
|
.B = B |
67 |
|
|
|
68 |
|
|
End With |
69 |
|
|
|
70 |
|
|
End Function |
71 |
|
|
|
72 |
|
|
Public Function Benchmark(lPointer) As Long |
73 |
|
|
|
74 |
|
|
Static colBenchmarks As New Collection |
75 |
|
|
|
76 |
|
|
If lPointer > 0 Then |
77 |
|
|
|
78 |
|
|
Benchmark = GetTickCount - colBenchmarks(lPointer) |
79 |
|
|
' colBenchmarks.Remove lPointer |
80 |
|
|
|
81 |
|
|
Else |
82 |
|
|
|
83 |
|
|
Benchmark = colBenchmarks.Count + 1 |
84 |
|
|
colBenchmarks.Add GetTickCount |
85 |
|
|
|
86 |
|
|
End If |
87 |
|
|
|
88 |
|
|
End Function |
89 |
|
|
|
90 |
|
|
Public Function UnQuote(strTerm As String) As String |
91 |
|
|
|
92 |
|
|
UnQuote = Replace(strTerm, """", "") |
93 |
|
|
|
94 |
|
|
End Function |