Reader small image

You're reading from  Game Physics Cookbook

Product typeBook
Published inMar 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781787123663
Edition1st Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Gabor Szauer
Gabor Szauer
author image
Gabor Szauer

Gabor Szauer has been making games since 2010. He graduated from Full Sail University in 2010 with a bachelor's degree in game development. Gabor maintains an active Twitter presence, and maintains a programming-oriented game development blog. Gabor's previously published books are Game Physics Programming Cookbook and Lua Quick Start Guide, both published by Packt.
Read more about Gabor Szauer

Right arrow

Oriented Bounding Box


An Oriented Bounding Box (OBB), is the 3D equivalent of the 2D oriented rectangle. An OBB is defined by a position, half-extents, and some orientation. There are several ways to store the orientation for a bounding box. One way would be to store a vector which has each component corresponding to the angle of rotation on an axis. A better way is to treat the orientation as a 3D matrix, using the mat3 struct:

Getting ready

We are going to create a new structure to represent an Oriented Bounding Box. This new OBB structure is going to be composed of a position, half extents, and some orientation. The position and size will be represented by vectors, but the rotation will be stored as a matrix. Storing the rotation as a matrix makes sense because no matter how we store the rotation, to render the OBB it will need to be converted into a matrix at some point.

How to do it

Follow these steps to implement a 3D oriented bounding box:

  1. Declare the new OBB structure in Geometry3D.h...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Game Physics Cookbook
Published in: Mar 2017Publisher: PacktISBN-13: 9781787123663

Author (1)

author image
Gabor Szauer

Gabor Szauer has been making games since 2010. He graduated from Full Sail University in 2010 with a bachelor's degree in game development. Gabor maintains an active Twitter presence, and maintains a programming-oriented game development blog. Gabor's previously published books are Game Physics Programming Cookbook and Lua Quick Start Guide, both published by Packt.
Read more about Gabor Szauer