<< Chapter < Page Chapter >> Page >

Preview of coming attractions

In case you are wondering where we are heading as we go down this path, I recommend that you skip ahead to the modules titled Our First 3D Game Program and A First-Person Shooter Game . Copy, compile and run the 3D game programs named GM01Test08 and Cannonball01 along with the required game-math libraries.

While the graphics and the story lines for those two game programs are rudimentary, the mathematics involved are significant. (After all, this is a course in game math and not a course in game design or high-quality graphics.)

Preview of this module

I will present and explain a significantly updated game-math library in this module.

I will also present and explain six different sample programs that show how to use the new features in the updated library.

By studying the library and the sample programs, you will learn

  • how to update the game-math library to support 3D math,
  • how to program the equations for projecting a 3D world onto a 2D plane,
  • how to add vectors in 3D,
  • about scaling, translation, and rotation of a point in both 2D and 3D,
  • about the rotation equations and
  • how to implement them in both 2D and 3D, and much more.

I will also provide exercises for you to complete on your own at the end of the module. The exercises will concentrate on the material that you have learnedin this and previous modules.

Discussion and sample code

In this section, I will present and explain a significantly updated version of the game-math library named GM01 .

In addition, I will present and explain the following programs that use the update game-mathlibrary.

The game-math library named GM01

A complete listing of the updated game-math library named GM01 is provided in Listing 26 near the end of the module.

A major update to add 3D capability

This is a major update to the game-math library. This version updates the earlier version named GM2D04 to a new version named simply GM01 . The primary purpose of the update was to add 3D capability for all of the 2Dfeatures provided by the previous version. Because both 2D and 3D capabilities are now included in the library, it is no longer necessary todifferentiate between the two in the name of the class. Therefore, this version is simply named GM01 .

3D to 2D projections

Adding 3D capability was tedious, but not particularly difficult in most areas of the library. However, adding 3D capability entailed majorcomplexity in one particular area: drawing the objects. It isdifficult to draw a 3D object on a 2D screen and have the drawing appear to be 3D. This requires a projection process to project each point in the 3Dobject onto the correct location on a 2D screen. There are a variety of ways to do this. This 3D library uses an approach often referred to as an oblique parallel projection . You can Google that name to learn more about the technical details of the process.

Eliminating the y-axis confusion

In addition to adding 3D capability, this version of the game library also eliminates the confusion surrounding the fact that the default direction of the positive y-axisis down the screen instead of up the screen as viewers have become accustomed to. If you funnel all of your drawing tasks through the library and don'tdraw directly on the screen, you can program under the assumption that the positive direction of the y-axis is up.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Game 2302 - mathematical applications for game development. OpenStax CNX. Jan 09, 2016 Download for free at https://legacy.cnx.org/content/col11450/1.33
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Game 2302 - mathematical applications for game development' conversation and receive update notifications?

Ask