/
1919.html
165 lines (111 loc) · 5.57 KB
/
1919.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
VB Eratta<br/>
========================================================================<br/>
Chapter 1, Page 7<br/>
<br/>
LinGrBrush = New Drawing2D.LinearGradientBrush(...)<br/>
the end of each line is missing the underscore "_" continuation character<br/>
========================================================================<br/>
Chapter 1, Page 10<br/>
<br/>
If (Dx > (R1.extentX+R2.ExtentX) And (Dy > (R1.ExtentY+R2.ExtentY)) Then ...<br/>
should be<br/>
If (Dx < (R1.extentX+R2.ExtentX) And (Dy < (R1.ExtentY+R2.ExtentY)) Then ...<br/>
//overlap<br/>
Else<br/>
//no overlap<br/>
End If<br/>
========================================================================<br/>
Chapter 1, Page 16<br/>
<br/>
Some readers have indicated that the Implementation of CircleIntersect at the bottom of Page 18 is erroneous,<br/>
indicating that the call to Math.Sqr (squaring function) should be Math.Sqrt (Square root). This is not an error.<br/>
Kind of. The error is that we should have used Math.Pow. Math.Sqr isn't a valid function. In addition, the <br/>
return result:<br/>
return Radius * Radius < Dist<br/>
should be<br/>
return Dist < Radius * Radius<br/>
In order to simplify understanding this collision test, I've added a class and an Nunit test harness to help.<br/>
The class is AxisAlignedBoundingBox and the test is AABBTest. Please refer to this code instead of the code snippets <br/>
on page 16.<br/>
========================================================================<br/>
Chapter 1, Page 19<br/>
<br/>
Figure 1-17 says<br/>
Dividing a screen into 64 zones<br/>
should say<br/>
Dividing a screen into 256 zones<br/>
========================================================================<br/>
Chapter 1, Page 22<br/>
<br/>
The extension to Arvo's algorithm on this page is incorrect. Adding a Z axis<br/>
check to the AxisAlignedBoundingBox and test code (mentioned above) will yield<br/>
correct results.<br/>
========================================================================<br/>
Chapter 1, Page 34<br/>
<br/>
Square.Draw(PicBackground.Handle)<br/>
should be<br/>
Square.Show(PicBackground.Handle)<br/>
========================================================================<br/>
Chapter 1, page 50<br/>
<br/>
Private Sub CmdStart_Click event handler must have this value set somewhere<br/>
in the method:<br/>
CmdStart.Enabled = False<br/>
========================================================================<br/>
Chapter 6, Pg 292 -<br/>
<br/>
Until the December version of the DirectX SDK is released, I needed to create a workaround to a bug I found in <br/>
the Microsoft.DirectX.Direct3D.Font.DrawText methods.<br/>
The problem is that there are two slightly different methods you can call:<br/>
Public Function DrawText( _<br/>
ByVal sprite As Sprite, _<br/>
ByVal text As String, _<br/>
ByRef rect As Rectangle, _<br/>
ByVal format As DrawTextFormat, _<br/>
ByVal color As Color _<br/>
) As Integer<br/>
And <br/>
Public Function DrawText( _<br/>
ByVal sprite As Sprite, _<br/>
ByVal text As String, _<br/>
ByRef rect As Rectangle, _<br/>
ByVal format As DrawTextFormat, _<br/>
ByVal color As Color _<br/>
) As Integer<br/>
The only difference is that one uses a ByRef param for Rectangle and the other a ByVal.<br/>
But, according to VB, it is an error to have such a thing -- two identically-named methods cannot be overloaded<br/>
if they only differ by parameters declared as ByRef and ByVal. <br/>
As a result, I needed to create a C# wrapper library (Apress.GameProgramming.DrawTextWorkAround) that allowed me to<br/>
draw the text.<br/>
So, this line:<br/>
DrawingFont.DrawText(Nothing, "X: " + Destination.X.ToString() + " Y: " + Destination.Y.ToString(), _<br/>
New Rectangle(5, 5, Me.Width, Me.Height), Direct3D.DrawTextFormat.NoClip, Color.White)<br/>
Is replaced by a reference to the DrawTextWorkAround DLL and this line<br/>
Workaround.DrawText("X: " + Destination.X.ToString() + " Y: " + Destination.Y.ToString())<br/>
Don't forget that the Workaround object must be reinitialised every time InitializeDeviceObjects is called.<br/>
========================================================================<br/>
Chapter 6, pg 297<br/>
<br/>
The new SDK simply returns an identical reference to a mesh if you call Mesh.Clean and nothing changes, so these <br/>
lines of code:<br/>
TempMesh = Mesh.Clean(CleanType.Optimization, SystemMemoryMesh, AdjacencyBuffer, AdjacencyBuffer, ErrorString)<br/>
SystemMemoryMesh.Dispose()<br/>
SystemMemoryMesh = TempMesh<br/>
Will yield a nulled SystemMemoryMesh if Mesh.Clean does nothing. You must explicitly check to verify that the meshes <br/>
are identical by using the Equals method:<br/>
TempMesh = Mesh.Clean(CleanType.Optimization, SystemMemoryMesh, AdjacencyBuffer, AdjacencyBuffer, ErrorString)<br/>
If Not TempMesh.Equals(SystemMemoryMesh) Then<br/>
SystemMemoryMesh.Dispose()<br/>
SystemMemoryMesh = TempMesh<br/>
End If<br/>
========================================================================<br/>
Chapter 6, pg 298<br/>
<br/>
The Managed DirectX mesh flag OptimizeAttrSort has been changed to OptimizeAttributeSort to conform to Microsoft<br/>
coding standards.<br/>
========================================================================<br/>
Chapter 6/7<br/>
<br/>
The shell code for the Spacewar3D game used the PureDevice flag when creating the device caps. This resulted in very<br/>
strange side-effects or non-functional programs. That flag has been terminated with prejudice.<br/>