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 1.4

COLUMN

Bouncing Off The Walls

Using The Bounds3D Class

Issue: 1.4 (February/March 2003)
Author: Joe Nastasi
Author Bio: Joe Nastasi has been a programmer since 1977 and a full-time REALbasic consultant since version 1.0. He is also the developer of a spacecraft simulator, A-OK! The Wings of Mercury, which was recently awarded a Cubie for Educational software.
Article Description: No description available.
Article Length (in bytes): 12,450
Starting Page Number: 38
Article Number: 1420
Resource File(s):

Download Icon 1420.zip Updated: 2013-03-11 19:07:56

Related Web Link(s):

http://www.oreilly.com/catalog/physicsgame/

Excerpt of article text...

Now that we've covered the basics of loading, moving, and lighting 3D objects, let's cover a slightly deeper topic: collision detection.

My Personal Space

REALbasic 4.5 introduced the concept of Bounds as a method of detecting collisions and determining if an object is in view. A new class, Bounds3D forms the core of this functionality.

A bounding box or bounding sphere is a numerical representation of the volume that an Object3D takes up. You can choose either a box aligned to the object's axis or a sphere whose center lies at the center of the object. Which one is best is largely a judgement call: in most cases you want to get the bounding area as close to the actual volume as possible. In some cases you may want to make the volume smaller or larger than the Object3D it represents, so that the software detects the object when it's closer or farther away, respectively.

While you could calculate the size of a Bounds3D yourself, RB3D will do it for you using its CalculateBounds method. Every Object3D has a Bounds3D property bound to it. To calculate a bounding area, decide which which type of area shape is best for your model and execute the following:

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