Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 2.4

FEATURE

BONK -- Ouch!

Spherical Collision Detection and Response in 3D

Issue: 2.4 (March/April 2004)
Author: Lars Jensen
Author Bio: Lars Jensen started programming before many of you started breathing...and he'll still be at it after you're all dust! Bwahahahaaa-a-a-a...
Article Description: No description available.
Article Length (in bytes): 39,455
Starting Page Number: 23
Article Number: 2412
Resource File(s):

Download Icon 2412.zip Updated: 2013-03-11 19:07:57

Related Web Link(s):

http://www.gamedev.net/reference/list.asp?categoryid=45#99
http://www.gamedev.net/reference/articles/article1234.asp
http://www.wheatchex.com/projects/collisions
http://www.quesa.org/
http://mathworld.wolfram.com/QuadraticEquation.html
http://mathworld.wolfram.com/VietasFormulas.html

Excerpt of article text...

Collision detection (figuring out whether objects come in contact with one another) and its sibling, collision response (figuring out what to do about it) are rich, complex topics in computer simulations of the physical world. There are many such simulations: computer-aided design tools, movie special effects, even screen savers... and, of course, games.

In Issue 2.2 (Oct/Nov 2003) of REALbasic Developer, Thomas Reed's article Collision Detection and Response showed how to simulate a round ball bouncing off a flat surface. In this article, we'll cover a related topic: how to simulate collisions among spheres moving in a 3D environment, and how to make them react in a fairly realistic way. Even if your objects aren't actually spherical, the collision detection technique code can serve as a quick initial test, after which you can investigate potential collisions in more detail.

We'll look at a few fast, general routines to handle this situation, along with their derivations, and a general framework in which to make them run. You can skip the math and physics if you like, but you'll need to know vector arithmetic to use the code.

We'll also look at building a special-purpose tool that makes it quick and easy to test these routines, plus any refinements you might come up with on your own. The completed tool is part of the download for this article, and represents a professional approach to isolating and testing important parts of your system that might be impractical to test in the "deployed environment" (that is, the game you're writing). It sounds very gritty and industrial, but you'll see that REALbasic's simplicity makes it inviting and -- dare I say it? -- even a little fun.

Organization: Frames and Subframes

Before we dive head-first into equations, let's consider our task: simulate a bunch of spherical bodies bouncing off each other, like a game of billiards in three dimensions. Such simulations often work by repeatedly calling a "frame driver" -- a routine that figures out what has happened to everything in the simulation since the last time it was called.

...End of Excerpt. Please purchase the magazine to read the full article.