Part 3. The Sandy Primitives
The cylinder
Here is a very useful primitive. The author has made the Cylinder class very flexible, and it can show up in many variants. You will soon notice that a cylinder may have more forms than you think. Here is the constructor.
function Cylinder( p_sName:String = null, p_nRadius:Number=100, p_nHeight:Number=100, p_nSegmentsW:Number=8, p_nSegmentsH:Number=6, p_nTopRadius:Number=NaN, p_bExcludeBottom:Boolean=false, p_bExludeTop:Boolean=false, p_bWholeMapping:Boolean = true )
That's a mouth full ;)
It is not so complicated as it may seem. First we have the radius and height
of the cylinder, by default 100 Sandy units. Then we determine in how may
segments we want do divide the cylindrical surface, horizontally and
vertically. So far all is the same as for the Plane3D and the Sphere.
It is the rest of the parameters make the Cylinder so flexible. Setting another value for top radius will make the cylinder conical, creating a truncated cone. If it is set to 0, we get a cone.
Setting the next two Boolean parameters to false will inhibit the creation the top and/or bottom surfaces. The last parameter determines how textures are applied to the cylinder.
So here's the default cylinder we get, if we don't pass any arguments, except name.
shape = new Cylinder('Cylinder');
The camera is mode a bit further upwards. Rotate to see the form.
Well, not much of a cylinder, rather a straight prism with an octagonal base. The reason, of course, is that by default we have 8 segments horizontally.
To create a better cylinder, we have to increase the horizontal quality.
shape = new Cylinder('Cylinder', 50, 80, 20, 2 );
Many other possibilities exist, and I'll leave it for you to experiment
with.
I cannot hold myself from showing you some of them.
Maybe also check frame rate - this last was much less demanding, when I set down from 30 to 8, but motion was better.
The Torus
The Torus ( donut, doughnut ) is a bit more complicated than the other primitives, but it is fun. Here is the signature
public function Torus( p_sName : String=null, p_nLargeRadius:Number=100, p_nSmallRadius:Number=50, p_nSegmentsW:Number=12, p_nSegmentsH:Number=8 )
The large radius is measured from the center of the torus to the middle circle in the tube, the small radius is the radius of the tube. As before we can set the number of segments or polygons in two directions.
shape = new Torus( 'Torus 1');
The large radius for the default Torus is 100, which means we have to back up the camera a bit to z = - 500, to get a good view on the torus.
That's all for this session.
Sandy 3.0 is brand new at the time of this writing, so things may change.
Your comment are most welcome! petit -at- petitpub.com or use my blog form.
In the next session, we'll have a first look at basic transforms.
how to move things around in a Sandy world.