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 17 in printed book and digital formats -- plus a one-year subscription (beginning with 18.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 4.4


Presto Chango!

Dynamic Textures

Issue: 4.4 (March/April 2006)
Author: Joe Nastasi
Author Bio: Joe Nastasi is the president of Pyramid Design, the developers of A-OK! The Wings of Mercury, A-OK! Spacecraft Simulation System and FTP Suite.
Article Description: No description available.
Article Length (in bytes): 6,088
Starting Page Number: 38
Article Number: 4416
Related Link(s): None

Excerpt of article text...

In both A-OK! The Wings of Mercury and A-OK! Spacecraft Simulation System, there is a requirement to have an Earth model. Unlike many space games, the camera is much closer to the surface and therefore, really puts the texture to the test. It gets blurry real quick. A-OK! Wings of Mercury was released in early 2002 and the graphic cards in the Macs (it was not released on Windows until November, 2005) limited the texture to 512 x 512 pixels.

Since the product also had to support older cards as well, I needed to be able to use smaller textures. Due to the limitations of the RB3D API, I was forced to build three Earth models with identical geometry, but progressively lower resolution textures. The model was selected by a popup menu in the preference window.

With REALbasic 2005 Release 3, RB3D gained the ability to directly access an Object3D's texture. So now, instead of having three models, one Earth model will suffice; we just have to swap the texture! An Object3D can have multiple instances of the new Material class. In our case, only one is required. A Material class can apply a DiffuseColor or a Texture. We will use the Texture property, which is a subclass of the Picture class.

It's a fair question to ask: "what's the advantage of swapping textures instead of entire models?" The global geometry was rather big, so there is space saving, but that's not a big deal. The main reason is flexibility.

Having separating texture and geometry has been a standard technique in real time 3D for years. Let's say that someone wants to orbit Mars instead of Earth. Physical and orbital physics differences aside, all that has to be done is to replace the Earth texture file with one of Mars. As long as the size specifications and image orientation match, you will be orbiting the red planet in no time.

So let's say we have three texture files in three different resolutions like those shown in Table 1. Our user interface can then have a PopupMenu that is used to select the desired resolution, label "Low," "Medium" and "High," for instance. In the PopupMenu's Change event:

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