This code works just fine. The "ball" bounces around the screen but I had to hard code the collision detection boundaries from -2.0 to 2.0 and -1.2 to 1.2 instead of using the Viewport width and height properties.
Most of the various XNA sources talk about using unit values because it keeps the math simpler. This makes sense, but the piece I'm missing is how do I then transform the primitive position to regular screen coordinates? I could iterate through the VertexPositionColor array and multiply each Position vertex, but using that approach, I might as well just hard code the final screen coordinates to begin with.
I know there's something painfully obvious I'm overlooking but I'm just not catching it. Thanks in advance for any suggestions.
The Projection and View matrices, which are part of what should be you camera object (you did not post anything that indicates how you are using these matrices) are what translate world transformations (scale, orientation, and position) to screen coordinates, and vice versa, if you have screen coordinates and you swap the multiplication order of the matrices, you get world transformation back.
Piece of advice, your ball object is retrieving the graphics device manager and basic effect shader every frame, this is inefficient. You should find another way to do things.
One way would be to store permanently these two objects in your Render GameComponent and have it access the vertex buffers to be drawn directly.
Thanks for the suggestions regarding the graphics device manager. These are the kinds of tips that I hope to pick up during this course. As far a the Perspective and View Matrices are concerned, I just did the standard assignment found in most of the samples and updated the references to them in my BasicEffect object which I access as a game service to avoid having to expose it globally or pass it around to each separate class as described in Ch 5 of the text. I'll post the additional code tonight, but here's basically what I did:
For the Perspective Matrix, I used Matrix.CreatePerspectiveFieldOfView passing in the PiOver4 MathHelper property to set the angle to 45 degrees, the Viewport AspectRatio, and set the near and far clipping planes to 1.0f and 100.0f.
For the View Matrix I set the camera reference to (0, 0, 3), target pointing at the origin, and up vector using Vector.Up.
I get how the perspective matrix works to create a viewing box that encompasses the size of the screen, but the piece I'm not seeing in any of the samples is the World matrix being multiplied by some Vector or Matrix that scales it from those smaller unit values we pass in when drawing the primitives to something that matches our standard 800x480 Viewport. So when I move the rectangle in the update method, it only takes fractional increments to move it from one side of the screen to the other.
Well, just before calling draw on the effect, you set the world matrix of the object you are about to draw, the multiplication of the world matrix to the view and projection is done internally by the effect, this allows you to change the world matrix for each object while view is not likely to change more than once per frame (updating camera position) and projection is even less likely to change during gameplay.