Packagesandy.primitive
Classpublic class Cylinder
InheritanceCylinder Inheritance Shape3D Inheritance ATransformable Inheritance Node
ImplementsPrimitive3D
SubclassesCone

The Cylinder class is used for creating a cylinder primitive, a cone or a truncated cone.

All credits go to Tim Knipt from suite75.net who created the AS2 implementation. Original sources available at : http://www.suite75.net/svn/papervision3d/tim/as2/org/papervision3d/objects/Cylinder.as


Example
To create a cylinder with a base radius of 150 and a height of 300, with default number of faces, use the following statement:
     var cyl:Cylinder = new Cylinder( "theCylinder", 150, 300 );
  
To create a truncated cone, you pass a top radius value to the constructor
     var tCone:Cylinder = new Cylinder( "trunkCone", 150, 300, 0, 0, 40 );
  



Public Properties
 PropertyDefined by
 InheritedaPolygons : Array
The array of polygons building this object.
Shape3D
 Inheritedappearance : Appearance
The appearance of this object.
Shape3D
 InheritedboundingBox : BBox
The bounding box of this node IMPORTANT: Do not modify it unless you perfectly know what you are doing
Node
 InheritedboundingSphere : BSphere
The bounding sphere of this node IMPORTANT: Do not modify it unless you perfectly know what you are doing
Node
 Inheritedbroadcaster : BubbleEventBroadcaster
The broadcaster

The broadcaster is used to send events to listeners.
This property is a BubbleEventBroadcaster.

Node
 Inheritedchanged : Boolean = false
This property set the cache status of the current node.
Node
 Inheritedcontainer : Sprite
The contianer for this object.
Shape3D
 Inheritedculled : CullingState
This property represent the culling state of the current node.
Node
 InheritedDEFAULT_APPEARANCE : Appearance
[static] Default appearance for Shape3D instances.
Shape3D
 InheritedDEFAULT_MATERIAL : Material
[static] Default material for the DEFAULT_APPEARANCE object
Shape3D
 Inheriteddepth : Number
The depth of this object.
Shape3D
 InheriteddepthSorter : IDepthSorter
Apply a new depth sorter to all the polygons.
Shape3D
 Inheriteddisable : Boolean = false
Disable the local transformations applied to this Node if set to false.
ATransformable
 InheritedenableBackFaceCulling : Boolean
Should back face culling be enabled for this object?.
Shape3D
 InheritedenableClipping : Boolean = false

Enable the Frustum clipping on the visible polygons.

Shape3D
 InheritedenableEvents : Boolean
Enables the event system for mouse events.
Shape3D
 InheritedenableForcedDepth : Boolean = false
Should forced depth be enable for this object?.
Shape3D
 InheritedenableInteractivity : Boolean
Enable the interactivity on this shape and its polygon.
Shape3D
 InheritedenableNearClipping : Boolean = false

Enable the Frustum near plane clipping on the visible polygons.

Shape3D
 InheritedforcedDepth : Number = 0
The forced depth for this object.
Shape3D
 Inheritedgeometry : Geometry3D
The geometry of this object.
Shape3D
 InheritedgeometryCenter : Vector
This property call allows you to get the geometryCenter offset vector of the Shape.
Shape3D
 InheritedinvModelMatrix : Matrix4
This property will remains null until a material needs it, defining the SandyFlag INVERT_MODEL_MATRIX In that case, that property will return the invert model matrix on that node
Shape3D
 Inheritedmatrix : Matrix4
ATransformable
 Inheritedname : String
Name of this node.
Node
 Inheritedout : Vector
Forward direction ( local z ) in parent coordinates.
ATransformable
 Inheritedpan : Number
Pans this object around the local y axis.
ATransformable
 Inheritedparent : Node
The parent node of this node.
Node
 Inheritedroll : Number
Rolls this object around the local z axis.
ATransformable
 InheritedrotateX : Number
Rotates this object around an axis parallel to the parents x axis.
ATransformable
 InheritedrotateY : Number
Rotates this object around an axis parallel to the parents y axis.
ATransformable
 InheritedrotateZ : Number
Rotates this object around an axis paralell to the parents z axis.
ATransformable
 InheritedscaleX : Number
x scale of this object.
ATransformable
 InheritedscaleY : Number
y scale of this object.
ATransformable
 InheritedscaleZ : Number
z scale of this object.
ATransformable
 Inheritedscene : Scene3D = null
Reference to the scene is it linked to.
Node
  segmentsH : Number
The number of vertical segments.
Cylinder
  segmentsW : Number
The number of horizontal segments.
Cylinder
 Inheritedside : Vector
Side direction ( local x ) in parent coordinates.
ATransformable
 Inheritedtarget : Vector
The position in the parent frame this object should "look at".
ATransformable
 Inheritedtilt : Number
Tilts this object around the local x axis.
ATransformable
 Inheritedup : Vector
Up direction ( local y ) in parent coordinates.
ATransformable
 InheriteduseSingleContainer : Boolean
setter that allow user to change the way to render this object.
Shape3D
 Inheritedvisible : Boolean = true
Specify the visibility of this node.
Node
 InheritedvisiblePolygonsCount : uint
Shape3D
 Inheritedx : Number
x position of this object in its parent frame.
ATransformable
 Inheritedy : Number
y position of this object in its parent frame.
ATransformable
 Inheritedz : Number
z position of the node in its parent frame.
ATransformable
Protected Properties
 PropertyDefined by
 Inheritedm_bUseSingleContainer : Boolean = true
Shape3D
 Inheritedm_nDepth : Number = 0
Shape3D
 Inheritedm_oContainer : Sprite
Shape3D
 Inheritedm_oEB : BubbleEventBroadcaster
Node
 Inheritedm_oGeomCenter : Vector
Shape3D
 Inheritedm_oPreviousOffsetRotation : Vector
ATransformable
 Inheritedm_tmpMt : Matrix4
ATransformable
 Inherited_oScale : Vector
ATransformable
 Inherited_p : Vector
ATransformable
 Inherited_vOut : Vector
ATransformable
 Inherited_vSide : Vector
ATransformable
 Inherited_vUp : Vector
ATransformable
Public Methods
 MethodDefined by
  
Cylinder(p_sName:String = null, p_nRadius:Number = 100, p_nHeight:Number = 100, p_nSegmentsW:Number = 8, p_nSegmentsH:Number = 6, p_nTopRadius:Number, p_bExcludeBottom:Boolean = false, p_bExludeTop:Boolean = false, p_bWholeMapping:Boolean = true)
Creates a Cylinder primitive or truncated cone.
Cylinder
 Inherited
addChild(p_oChild:Node):void
Adds a new child to this node.
Node
 Inherited
addEventListener(p_sEvt:String, p_oL:*):void
Adds a listener for the specified event.
Node
  
CALCUL_RADIUS_FROM_SIDE(p_nSideNumber:uint, p_nSideWidth:uint):Number
[static] Calculates the radius depending on the number of sides you want and their width.
Cylinder
 Inherited
clear():void
Clears the graphics object of this object's container.
Shape3D
 Inherited
clone(p_sName:String = "", p_bKeepTransform:Boolean = false):Shape3D
This method returns a clone of this Shape3D.
Shape3D
 Inherited
cull(p_oScene:Scene3D, p_oFrustum:Frustum, p_oViewMatrix:Matrix4, p_bChanged:Boolean):void
Tests this node against the camera frustum to get its visibility.
Shape3D
 Inherited
destroy():void
Destroy this object and all its faces container object is removed, and graphics cleared.
Shape3D
 Inherited
display(p_oScene:Scene3D, p_oContainer:Sprite = null):void
Performs a z-sorting and renders the objects visible polygons.
Shape3D
  
generate(... arguments):Geometry3D
Generates the geometry for the cylinder.
Cylinder
  
Returns a PrimitiveFace object ( an array of polygons ) defining the bottom face.
Cylinder
 Inherited
getChildByName(p_sName:String, p_bRecurs:Boolean = false):Node
Returns the child node with the specified name.
Node
  
getFace(p_nFace:uint):PrimitiveFace
Returns a PrimitiveFace object ( an array of polygons ) defining the specified face.
Cylinder
 Inherited
getPosition(p_sMode:String = "local"):Vector
Returns the position of this group or object.
ATransformable
  
Returns a PrimitiveFace object ( an array of polygons ) defining the top face.
Cylinder
 Inherited
hasParent():Boolean
Tests if this node has a parent.
Node
 Inherited
initFrame():void
Initiates the local coordinate system for this object.
ATransformable
 Inherited
isParent(p_oNode:Node):Boolean
Tests if the node passed in the argument is parent of this node.
Node
 Inherited
lookAt(p_nX:Number, p_nY:Number, p_nZ:Number):void
Makes this object "look at" the specified position in the parent frame.
ATransformable
 Inherited
moveForward(p_nD:Number):void
Translates this object along its forward vector ( local z ) in the parent frame.
ATransformable
 Inherited
moveHorizontally(p_nD:Number):void
Translates this object parallel to its parent zx plane and in its forward direction.
ATransformable
 Inherited
moveLateraly(p_nD:Number):void
Translates this object laterally in its parent frame.
ATransformable
 Inherited
moveSideways(p_nD:Number):void
Translates this object along its side vector ( local x ) in the parent frame.
ATransformable
 Inherited
moveUpwards(p_nD:Number):void
Translates this object along its up vector ( local y ) in the parent frame.
ATransformable
 Inherited
moveVertically(p_nD:Number):void
Translates this object vertically in ots parent frame.
ATransformable
 Inherited
perform(p_iOperation:INodeOperation):void
Performs an operation on this node and all of its children.
Node
 Inherited
remove():void
Removes this node from the node tree, saving its child nodes.
Node
 Inherited
removeChildByName(p_sName:String):Boolean
Removes the child node with the specified name.
Node
 Inherited
removeEventListener(p_sEvt:String, p_oL:*):void
Removes a listener for the specified event.
Node
 Inherited
render(p_oScene:Scene3D, p_oCamera:Camera3D):void
Renders this 3D object.
Shape3D
 Inherited
rotateAxis(p_nX:Number, p_nY:Number, p_nZ:Number, p_nAngle:Number):void
Rotate this object around the specified axis in the parent frame by the specified angle.
ATransformable
 Inherited
setPosition(p_nX:Number, p_nY:Number, p_nZ:Number):void
Sets the position of this object in coordinates of its parent frame.
ATransformable
 Inherited
swapCulling():void
Changes the backface culling side.
Shape3D
 Inherited
swapParent(p_oNewParent:Node):void
Moves this node to another parent node.
Node
 Inherited
toString():String
Returns a string representation of this object
Shape3D
 Inherited
translate(p_nX:Number, p_nY:Number, p_nZ:Number):void
Translate this object from it's current position with the specified offsets.
ATransformable
 Inherited
update(p_oScene:Scene3D, p_oModelMatrix:Matrix4, p_bChanged:Boolean):void
Updates this node or object.
ATransformable
 Inherited
Updates the bounding volumes of this object.
Shape3D
 Inherited
Updates the transform matrix of the current object/node before it is rendered.
ATransformable
Protected Methods
 MethodDefined by
 Inherited
_onInteraction(p_oEvt:Event):void
Shape3D
Public Constants
 ConstantDefined by
 Inheritedchildren : Array
The children of this node are stored inside this array.
Node
  DEFAULT_HEIGHT : Number = 100
[static] The default height for a cylinder.
Cylinder
  DEFAULT_RADIUS : Number = 100
[static] The default radius for a cylinder.
Cylinder
  DEFAULT_SCALE : Number = 1
[static] The default scale for a cylinder texture.
Cylinder
  DEFAULT_SEGMENTSH : Number = 6
[static] The default number of vertical segments for a cylinder.
Cylinder
  DEFAULT_SEGMENTSW : Number = 8
[static] The default number of horizontal segments for a cylinder.
Cylinder
 Inheritedid : uint
The unique id of this node in the node graph.
Node
  MIN_SEGMENTSH : Number = 2
[static] The minimum number of vertical segments for a cylinder.
Cylinder
  MIN_SEGMENTSW : Number = 3
[static] The minimum number of horizontal segments for a cylinder.
Cylinder
 InheritedmodelMatrix : Matrix4
Cached matrix corresponding to the transformation to the 0,0,0 frame system
Node
 InheritedviewMatrix : Matrix4
Cached matrix corresponding to the transformation to the camera frame system
Node
Property detail
segmentsHproperty
public var segmentsH:Number

The number of vertical segments.

segmentsWproperty 
public var segmentsW:Number

The number of horizontal segments.

Constructor detail
Cylinder()constructor
public 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, p_bExcludeBottom:Boolean = false, p_bExludeTop:Boolean = false, p_bWholeMapping:Boolean = true)

Creates a Cylinder primitive or truncated cone.

The cylinder is created at the origin of the world coordinate system, with its axis along the y axis, and with the bottom and top surfaces paralell to the zx plane

All arguments to the constructor have default values, and are optional. If you pass in a top radius, that is different from the bottom radius, a truncated cone is created.

By passing true values to one or both of p_bExcludeBottom and p_bExludeTop, you exclude the bottom and/or top surfaces from being created.

Parameters
p_sName:String (default = null) — A string identifier for this object.
 
p_nRadius:Number (default = 100) — Radius of the cylinder.
 
p_nHeight:Number (default = 100) — Height of the cylinder.
 
p_nSegmentsW:Number (default = 8) — Number of horizontal segments.
 
p_nSegmentsH:Number (default = 6) — Number of vertical segments.
 
p_nTopRadius:Number — An optional parameter for cone - or diverging cylinders.
 
p_bExcludeBottom:Boolean (default = false) — If set to true, the bottom face is not created.
 
p_bExludeTop:Boolean (default = false) — If set to true, the top face is not created.
 
p_bWholeMapping:Boolean (default = true) — Specifies how the material applied to the cylinder will be mapped. If set to false, the material will be mapped to each individual face, rather than to the whole cylinder.
Method detail
CALCUL_RADIUS_FROM_SIDE()method
public static function CALCUL_RADIUS_FROM_SIDE(p_nSideNumber:uint, p_nSideWidth:uint):Number

Calculates the radius depending on the number of sides you want and their width.

[ToDo: Elaborate on this a bit, please :) ]

Parameters
p_nSideNumber:uint — The number of sides the cylinder has
 
p_nSideWidth:uint — Width of a side

Returns
Number — The radius
generate()method 
public function generate(... arguments):Geometry3D

Generates the geometry for the cylinder.

Parameters
... arguments

Returns
Geometry3D — The geometry object for the cylinder.

See also

getBottom()method 
public function getBottom():PrimitiveFace

Returns a PrimitiveFace object ( an array of polygons ) defining the bottom face.

Returns
PrimitiveFace — The PrimitiveFace object of the bottom face.

See also

PrimitiveFace
getFace()method 
public function getFace(p_nFace:uint):PrimitiveFace

Returns a PrimitiveFace object ( an array of polygons ) defining the specified face.

Parameters
p_nFace:uint — The requested face

Returns
PrimitiveFace — The PrimitiveFace object of the specified face.

See also

PrimitiveFace
getTop()method 
public function getTop():PrimitiveFace

Returns a PrimitiveFace object ( an array of polygons ) defining the top face.

Returns
PrimitiveFace — The PrimitiveFace object of the top face.

See also

PrimitiveFace
Constant detail
DEFAULT_HEIGHTconstant
public static const DEFAULT_HEIGHT:Number = 100

The default height for a cylinder.

DEFAULT_RADIUSconstant 
public static const DEFAULT_RADIUS:Number = 100

The default radius for a cylinder.

DEFAULT_SCALEconstant 
public static const DEFAULT_SCALE:Number = 1

The default scale for a cylinder texture.

DEFAULT_SEGMENTSHconstant 
public static const DEFAULT_SEGMENTSH:Number = 6

The default number of vertical segments for a cylinder.

DEFAULT_SEGMENTSWconstant 
public static const DEFAULT_SEGMENTSW:Number = 8

The default number of horizontal segments for a cylinder.

MIN_SEGMENTSHconstant 
public static const MIN_SEGMENTSH:Number = 2

The minimum number of vertical segments for a cylinder.

MIN_SEGMENTSWconstant 
public static const MIN_SEGMENTSW:Number = 3

The minimum number of horizontal segments for a cylinder.