The most common way to obtain the geometry of a 3D model is from a file output from a modeling package like 3D Studio Max, Maya, or Blender, but it’s not the only way. In the case of simpler forms of geometry it is practical to generate it yourself using AS3 code. When you do this you eliminate the needed download and gain the flexibility to scale up or down the complexity of the model on a whim. Today’s article shows some AS3 code to generate spheres for all kinds of uses: planets in space simulators, placeholders for debugging physics simulations, and whatever else you can dream up.
Archive for category AS3
My article Stage3D Pipeline in a Nutshell is a conceptual journey through the phases of the 3D pipeline, but today I’m going to talk about the practical side. What code do you write if you want to transform points and vectors from one space to another? This article will show you how to do that.
Flash Player 11’s Stage3D
gives you only a few opcodes to do conditional logic and none of them are as effective as the good old if
in AS3. The most unique one of all is the KIL
opcode that discards the pixel being drawn. How does it work? How does it perform? Today we’ll find out!
This week’s article offers another useful utility function: indexedTrisToString
. This function is especially useful when dealing with 3D engines such as those based on Context3D.drawTriangles
or Graphics.drawTriangles
. It helps to untangle the complicated indices/vertices format that these API functions require into something much more readable and, therefore, debuggable.
It’s been a while since I’ve posted a utility function, but today I’m breaking the streak and posting a couple of related functions I frequently find useful in debugging: joinN
and joinNLabeled
. These functions are like Array.join
and Vector.join
, but they group elements of the array to make the resulting string much easier to read.
Amazingly, everything you see in a Stage3D
scene is one of two very basic elements: the solid background color and a triangle. Yes, realistic portrayals of human avatars, fantastical renderings of futuristic spaceships, and every special effect you’ve ever seen are nothing more than cleverly-processed triangles. Just how are they so cleverly processed to get these effects? Today’s article takes you through the journey these triangles take from lowly three-sided shapes to building blocks of immersive experiences.
Now that we know how to use textures with an alpha channel in rendering Stage3D
scenes, let’s see if we can cut the performance cost so we can use them more often. Today’s article will show some tricks to optimize your rendering loop.
Stage3D
makes a lot of common tasks more complicated. One such task is using a texture/image that has alpha on it. With classic 2D Flash, this is done automatically for us. With Stage3D
, we must resort to some obscure tricks. Today I’ll show you those tricks so you can use alpha textures in your Stage3D
-accelerated Flash app.
AS3 gives you arrays and a way to sort them, but no easy way to keep them sorted as you add elements to them. Today’s article discusses an easy way to do just that: build a sorted array and keep it sorted. As a bonus, the array provides very fast searching for the elements it contains.
If you want to check if one class inherits another without actually having instances of those classes, you may have read my article on Checking Class Inheritance. However, as the many comments quickly pointed out, the methods of checking this may have some flaws. There were also additional methods posted in the comments that should be added and tested. Today I’m adding them, testing them, and checking all of their validity to find the ultimate approach to check class inheritance.