
Using 3D Anti-aliasing
311
Determining whether anti-aliasing is supported
Not all 3D renderers can perform the additional calculations that anti-aliasing requires. If
you have a 3D sprite that you want to anti-alias, check first that the 3D renderer supports
anti-aliasing. The renderers that currently support anti-aliasing include the Director software
renderer, and DirectX 5.2 and DirectX 7.0.
If the 3D sprite is in channel 1 of the Score, you would test the
antiAliasingSupported
property of sprite 1, as shown in the following example:
if sprite(1).antiAliasingSupported = TRUE then
Turning on anti-aliasing
If the
antiAliasingSupported
property is
TRUE
, you can turn on anti-aliasing for the 3D sprite
by setting the sprite’s
antiAliasingEnabled
property to
TRUE
.
sprite(1).antiAliasingEnabled = TRUE
For example, if you have a 3D sprite in channel 5 and you want to turn on anti-aliasing for the
sprite when it first appears on the Stage, you would write a
beginSprite
script and attach it to
the sprite. Your script should contain code as shown in the following example:
-- Lingo syntax
on beginSprite
-- check whether anti-aliasing is supported by the current 3D renderer
if sprite(5).antiAliasingSupported = TRUE then
-- if it is, turn on anti-aliasing for the sprite
sprite(5).antiAliasingEnabled = TRUE
end if
end beginSprite
// JavaScript syntax
function beginSprite() {
// check whether anti-aliasing is supported by the current 3D renderer
if (sprite(5).antiAliasingSupported) {
// if it is, turn on anti-aliasing for the sprite
sprite(5).antiAliasingEnabled = true;
}
}
Turning off anti-aliasing
If you plan to animate any part of a 3D sprite, you might want to turn anti-aliasing off
temporarily to improve the animation performance. To do this, set the
antiAliasingEnabled
property for the sprite to
FALSE
. You can then set it back to
TRUE
when the animation is
complete.
It is a good idea to turn anti-aliasing on and off on separate handlers. For example, you might
want to animate a model, camera, or light while the mouse button is held down and stop the
animation when the mouse button is released. In that case you would turn off anti-aliasing in a
mouseDown
handler and turn it back on in a
mouseUp
handler, as shown in the following example:
-- Lingo syntax
on mouseDown
-- user interaction/animation is about to start so turn
-- anti-aliasing OFF
sprite(1).antiAliasingEnabled = FALSE
-- start animation
Summary of Contents for DIRECTOR MX 2004-USING DIRECTOR
Page 1: ...DIRECTOR MX 2004 Using Director...
Page 16: ...16 Chapter 1 Introduction...
Page 82: ...82 Chapter 3 Sprites...
Page 98: ...98 Chapter 4 Animation...
Page 134: ...134 Chapter 5 Bitmaps...
Page 242: ...242 Chapter 10 Sound and Synchronization...
Page 274: ...274 Chapter 11 Using Digital Video...
Page 290: ...290 Chapter 12 Behaviors...
Page 302: ...302 Chapter 13 Navigation and User Interaction...
Page 334: ...334 Chapter 15 The 3D Cast Member 3D Text and 3D Behaviors...
Page 392: ...392 Chapter 16 Working with Models and Model Resources...
Page 418: ...418 Chapter 18 Movies in a Window...
Page 446: ...446 Chapter 22 Managing and Testing Director Projects...