 |
 |
|
 | |
Primitives Tutorial
Cylinder
Although named cylinder, this primitive is also useful to create cones and tubes.

The set of properties for a cylinder model resource are:
Name | Default | Description | Range |
height | 50.0 | The height of the cylinder, i.e. the size along the Y axis | Any float larger than zero |
topRadius | 25.0 | The radius of the top of the cylinder. Set to zero to obtain a cone | Any float larger than or equal to zero |
bottomRadius | The radius of the bottom of the cylinder. Set to zero to create an ice cream cone! |
topCap | true | Determines the visibility of the caps | true or false |
bottomCap |
resolution | 20 | Determines the roundness of the cylinder. The higher the value, the larger the number of sides used to build the cylinder. Note however that the value does not correspond to the number of sides, think of it as a roundness factor. This setting has a direct influence on the performance. High values will produce smooth cylinders but will make your application run slower. | Any positive integer, larger than zero |
numSegments | 2 | Determines the number of segments along the Y axis. This setting has very little influence on the smoothness of the cylinder. However when using 3D lights it helps to provide a smoother look. Note that the higher the number the slower the application | Any positive integer, larger than zero |
startAngle | 0.0 | A cylinder is built sweeping a line segment around the y axis. The position of the two ends of the line segment depends on the bottomRadius, topRadius and height of the cylinder. The start and end angles determine where the sweep starts and ends. A full cylinder has a startAngle of 0.0 and an endAngle of 360.0. Half a cylinder, or half a tube, can be defined for instance setting the startAngle to 0.0 and the endAngle to 180.0. | Any float between 0.0 and the endAngle |
endAngle | 360.0 | Any float larger than startAngle and smaller or equal to 360.0 |
|
|
|
Half a cylinder: startAngle=0, endAngle=180 (the cylinder was rotated to get a better view)
|
Cylinder with resolution set to 2
|
Cylinder with bottomRadius set to 2
|
In order to retrieve the actual value of the startAngle of a model resource called "aCylin" you could write something like:
len = member("world").modelResource("aCylin").startAngle
The following script creates a cone. To try it create a new movie, add a Shockwave 3D member to the score, name it "world" and attach this script to the sprite.
on beginSprite me
w = member("world")
w.resetWorld()
mr = w.newModelResource("cyl",#cylinder,#front)
mr.topRadius = 0.0
m = member("world").newModel("aCylInstance",mr)
end
|