Article Preview
Buy Now
| Print: | |
| PDF: |
The Topographic Apprentice
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): 10,430
Starting Page Number: 38
RBD Number: 1420
Resource File(s):
1420.sit Updated: Friday, October 17, 2003 at 12:20 PM
Related Web Link(s):
http://www.oreilly.com/catalog/physicsgame/
Known Limitations: None
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.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|










