Intro:
Many people want to remove the jagged look to 3D renders. Some modern
graphics cards will do this automatically, but for the time being there's
no in-built function of Director 8.5 that allows this.
There is a solution detailed below, but it has certain problems, which
means that it might not be suitable for all applications. Having said
that, anti-aliasing is usually a pretty costly affair at the best of
times so if you want it, don't expect blindingly fast results! Ironically,
since one of the slowest things for a graphics card to do is send it's
data back to the main computer, it can sometimes work out quicker to
use software rendering than hardware rendering.
Method:
Each frame I grab the 3D member's image and copyPixels() it down
to half it's original size into a bitmap member. This bitmap member
is used by a sprite on-screen, thereby showing this new, reduced version.
This works because by default, when Director is asked to draw an image
smaller than the original, it resamples the image so it looks nicer.
Note this only happens when you use the COPY ink (usually the default).
One example might be you place a bitmap sprite on screen and animate
it shrinking to nothing. As soon as the sprite needs to be drawn smaller
than the original, Director resamples it. It looks a lot nicer, but
can ironically mean that the COPY ink isn't the fastest ink anymore.
Naughty Macromedia for not mentioning this anywhere at all in their
documention :)
In Practice:
There are several things that need to be taken into account:
Grabbing the
right size image from the 3D member.
This is taken care of by the following code:
member("3D
member name").defaultRect
= rect(0, 0, tWidth, tHeight)
where tWidth and tHeight should be TWICE the final size you wish to
see. EG if your stage size is 320x240 and you want the 3D sprite to
fill it, you will need to set it's defaultRect
= rect(0, 0, 640, 480).
Reducing the
image into the bitmap.
This is taken care of by the following code:
where tFinalWidth and tFinalHeight is the size you wish to see the
image at, and tWidth and tHeight is the size you set the member's
defaultRect to earlier.
Setting it all
up correctly.
You will most likely have to set the 3D member's directToStage
property to FALSE. This can simply be
done using the property inspector.