Essential Math Sample Code
This depot contains the sample code and example applications referenced in the book Essential Mathematics for Games and Interactive Applications, along with additional supplementary code and files that should be of interest to readers of the book.
The following platforms are supported:
- MacOS X (using Xcode)
- Windows (using Microsoft's Visual Studio development environment)
In addition to the demo code, we have included some text that was cut from the main text for length. These consist of two appendices reviewing trigonomety and calculus concepts, and a section of the first chapter covering fixed point numbers and arithmetic in more detail.
Installing The Libraries and Examples
You can clone the depot using
git clone https://github.com/jvanverth/essentialmath.git
Or you can download it directly.
Very little of the depot's contents are platform-specific, so all platforms are included in the same hierarchy.
Please consult the platform-specific README files for any additional platform-specific details regarding:
- System requirements
- Additional installation or configuration step
- How to build and run the demo applications
Supported platforms and their README files are as follows:
- Linux: src/README_LINUX.md
- MacOS X: src/README_MACOS.md
- Windows: src/README_WINDOWS.md
Source Directory Structure
The following is a listing of the directories and demos in src/:
/common - the set of libraries used in the book and by the demos
- /IvCollision - bounding volume classes and intersection methods
- /IvCurves - position-interpolation curve classes
- /IvEngine - classes and functions that support applications
- /IvEngine/OGL - OpenGL-specific application code
- /IvEngine/D3D11 - Direct3D 11 application code
- /IvGraphics - cross-platform rendering classes
- /IvGraphics/OGL - OpenGL-specific rendering code
- IvGraphics/D3D11 - Direct3D 11 rendering code
- /IvMath - basic 2-, 3-, and 4-dimensional vectors, 3x3 and 4x4 matrices, quaternions, rays, and other classes representing mathematical objects.
- /IvRandom - code for six simple random number generators
- /IvScene - classes implementing a basic hierarchical data structure
- /IvUtility - low-level system support code such as file I/O
In addition, after building, the /common directory will include two other directories, whose contents are derived from the libraries above:
Includes: When built, will contain all of the .h files for all of the Iv libraries. Building an Iv library (on any platform) will automatically copy that library's latest headers to this directory. The demo applications all reference this directory (using relative paths) for all Iv* headers. For those platforms using Makefiles, you will need to build the common directory to generate these files.
Libs: When built, will contain Debug and Release subdirectories for each supported platform. Building any Iv library on any platform will automatically update that library's target to the correct directory. For those platforms using Makefiles, you will need to build the common directory to generate these files.
/Examples - all of the demo applications referenced by the book text
/Ch04-Xforms - Contains the demos for Chapter 3: Affine Transformations
/Ch05-Orientation - Contains the demos for Chapter 5: Orientation Representations
/Ch06-Viewing - Contains the demos for Chapter 6: Viewing and Projection
/Ch07-Interpolation - Contains the demos for Chapter 7: Interpolation
/Ch08-GeometryColoring - Contains the demos for Chapter 8: Geometry and Textuting
/Ch09-Lighting - Contains the demos for Chapter 9: Lighting
/Ch10-Raster - Contains the demos for Chapter 10: Rasterization
/Ch11-RandomNumbers - Contains the demos for Chapter 11: Random Numbers
/Ch12-Collision - Contains the demos for Chapter 12: Intersection Testing
/Ch13-Simulation - Contains the demos for Chapter 13: Rigid Body Dynamics
/glfw - Contains the GLFW library and headers, which handles window creation and event handling for the OpenGL demos. The build systems for the demo applications and Iv libraries on the necessary platforms reference this directory via relative paths when looking for GLFW headers and libraries.
- Contains the OpenGL GLEW library and headers for Windows and those Linux platforms that need it. This is used to handle OpenGL 3.0 support and extensions. The build systems for the demo applications and Iv libraries on the necessary platforms may reference this directory via relative paths when looking for GLEW headers and libraries.
- Contains d3dcompiler_47.dll, which may be needed to build HLSL shaders when run as standalone apps.
Copyright (c) 2015, James M. Van Verth and Lars M. Bishop. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Essential Mathematics for Games and Interactive Applications nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JAMES M. VAN VERTH OR LARS M. BISHOP BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.