Packagesandy.core.scenegraph
Classpublic class Shape3D
InheritanceShape3D Inheritance ATransformable Inheritance Node
ImplementsIDisplayable
SubclassesBox, Cylinder, Hedra, Line3D, Plane3D, Sphere, Torus

The Shape3D class is the base class of all true 3D shapes.

It represents a node in the object tree of the world.
A Shape3D is a leaf node and can not have any child nodes.

It must be the child of a branch group or a transform group, but transformations can be applied to the Shape directly.



Public Properties
 PropertyDefined by
  aPolygons : Array
The array of polygons building this object.
Shape3D
  appearance : 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
 Inheritedchildren : Array
The children of this node are stored inside this array.
Node
  container : Sprite
[read-only] The contianer for this object.
Shape3D
 Inheritedculled : CullingState
This property represent the culling state of the current node.
Node
  DEFAULT_APPEARANCE : Appearance
[static] Default appearance for Shape3D instances.
Shape3D
  DEFAULT_MATERIAL : Material
[static] Default material for the DEFAULT_APPEARANCE object
Shape3D
  depth : Number
[read-only] The depth of this object.
Shape3D
 Inheriteddisable : Boolean = false
Disable the local transformations applied to this Node if set to false.
ATransformable
  enableBackFaceCulling : Boolean
Should back face culling be enabled for this object?.
Shape3D
  enableClipping : Boolean = false

Enable the Frustum clipping on the visible polygons.

Shape3D
  enableEvents : Boolean
[write-only] Enables the event system for mouse events.
Shape3D
  enableForcedDepth : Boolean = false
Should forced depth be enable for this object?.
Shape3D
  enableInteractivity : Boolean
Shape3D
  enableNearClipping : Boolean = false

Enable the Frustum near plane clipping on the visible polygons.

Shape3D
  forcedDepth : Number = 0
The forced depth for this object.
Shape3D
  geometry : Geometry3D
The geometry of this object.
Shape3D
  geometryCenter : Vector
This property call allows you to get the geometryCenter offset vector of the Shape.
Shape3D
 Inheritedmatrix : Matrix4
ATransformable
 InheritedmodelMatrix : Matrix4
Cached matrix corresponding to the transformation to the 0,0,0 frame system
Node
 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
 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
Getter for the tilt value
ATransformable
 Inheritedup : Vector
Up direction ( local y ) in parent coordinates.
ATransformable
  useSingleContainer : Boolean
[write-only] setter that allow user to change the way to render this object.
Shape3D
 InheritedviewMatrix : Matrix4
Cached matrix corresponding to the transformation to the camera frame system
Node
 Inheritedvisible : Boolean = true
Specify the visibility of this node.
Node
 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
  m_bUseSingleContainer : Boolean = true
Shape3D
  m_nDepth : Number = 0
Shape3D
  m_oContainer : Sprite
Shape3D
 Inheritedm_oEB : BubbleEventBroadcaster
Node
  m_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
  
Shape3D(p_sName:String = "", p_oGeometry:Geometry3D = null, p_oAppearance:Appearance = null, p_bUseSingleContainer:Boolean = true)
Creates a 3D object

[Todo: some more explanations]

Shape3D
 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
  
clear():void
Clears the graphics object of this object's container.
Shape3D
  
clone(p_sName:String = "", p_bKeepTransform:Boolean = false):Shape3D
This method returns a clone of this Shape3D.
Shape3D
  
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
  
destroy():void
Destroy this object and all its faces container object is removed, and graphics cleared.
Shape3D
  
display(p_oScene:Scene3D, p_oContainer:Sprite = null):void
Performs a z-sorting and renders the objects visible polygons.
Shape3D
 Inherited
getChildByName(p_sName:String, p_bRecurs:Boolean = false):Node
Returns the child node with the specified name.
Node
 Inherited
getChildFromId(p_nId:uint, p_bRecurs:Boolean = false):Node
Returns the child node with the specified id.
Node
 Inherited
getChildList():Array
Returns an array with all child nodes of this node.
Node
 Inherited
getPosition(p_sMode:String = "local"):Vector
Returns the position of this group or object.
ATransformable
 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
remove():void
Removes this node from the node tree, saving its child nodes.
Node
 Inherited
removeChildById(p_nId:Number):Boolean
Removes the child node with the specified id.
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
  
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
  
swapCulling():void
Changes the backface culling side.
Shape3D
 Inherited
swapParent(p_oNewParent:Node):void
Moves this node to another parent node.
Node
  
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
  
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
  
_onInteraction(p_oEvt:Event):void
Shape3D
Public Constants
 ConstantDefined by
 Inheritedid : uint
The unique id of this node in the node graph.
Node
Property detail
aPolygonsproperty
public var aPolygons:Array

The array of polygons building this object.

appearanceproperty 
appearance:Appearance  [read-write]

The appearance of this object.

Implementation
    public function get appearance():Appearance
    public function set appearance(value:Appearance):void
containerproperty 
container:Sprite  [read-only]

The contianer for this object. This container property exist if the useSingleContainer is set to true. It is a direct access to the Shape3D container to, for example, apply nice effects such as filters etc.

Implementation
    public function get container():Sprite
DEFAULT_APPEARANCEproperty 
public static var DEFAULT_APPEARANCE:Appearance

Default appearance for Shape3D instances. If no apperance is given, this default one will be applied using the DEFAULT_MATERIAL as front and back material

DEFAULT_MATERIALproperty 
public static var DEFAULT_MATERIAL:Material

Default material for the DEFAULT_APPEARANCE object

depthproperty 
depth:Number  [read-only]

The depth of this object. In case the useSingleContainer mode is enabled (default mode), this value returns the means depth of the Shape in the camera frame. This value is mainly used as a z-sorting value.

Implementation
    public function get depth():Number
enableBackFaceCullingproperty 
enableBackFaceCulling:Boolean  [read-write]

Should back face culling be enabled for this object?.

If set to false all faces of this object are drawn.
A true value enables the back face culling algorithm - Default true

Implementation
    public function get enableBackFaceCulling():Boolean
    public function set enableBackFaceCulling(value:Boolean):void
enableClippingproperty 
public var enableClipping:Boolean = false

Enable the Frustum clipping on the visible polygons. Enable this when you need a perfect intersection between the camera and some object shapes. In case you need to make the camera look inside and outide a box, or other immerssive things.

Important: Enable the clipping makes process a bit slower, especially with big scenes.

Specify if this object polygons should be clipped against the camera frustum planes.

enableEventsproperty 
enableEvents:Boolean  [write-only]

Enables the event system for mouse events.

When set to true, the onPress, onRollOver and onRollOut events are broadcast.
The event system is enabled or disabled for all faces of this object.
As an alternative, you have the possibility to enable events only for specific faces.

Once this feature is enabled, the animation is more CPU intensive.

Implementation
    public function set enableEvents(value:Boolean):void
enableForcedDepthproperty 
public var enableForcedDepth:Boolean = false

Should forced depth be enable for this object?.

If true it is possible to force this object to be drawn at a specific depth,
if false the normal Z-sorting algorithm is applied.

When correctly used, this feature allows you to avoid some Z-sorting problems.

enableInteractivityproperty 
enableInteractivity:Boolean  [read-write]Implementation
    public function get enableInteractivity():Boolean
    public function set enableInteractivity(value:Boolean):void
enableNearClippingproperty 
public var enableNearClipping:Boolean = false

Enable the Frustum near plane clipping on the visible polygons. Enable this when you need a perfect intersection between the front camera plane. This is mainly used when you need the camera to move on a long plane.

Important: Enable the clipping makes process a bit slower, especially with big scenes.

forcedDepthproperty 
public var forcedDepth:Number = 0

The forced depth for this object.

To make this feature work, you must enable the ForcedDepth system too.
The higher the depth is, the sooner the more far the object will be represented.

geometryproperty 
geometry:Geometry3D  [read-write]

The geometry of this object.

Implementation
    public function get geometry():Geometry3D
    public function set geometry(value:Geometry3D):void
geometryCenterproperty 
geometryCenter:Vector  [read-write]

This property call allows you to get the geometryCenter offset vector of the Shape. Modifying this vector will impact the way the shape is rendered, mainly its rotation center.

Implementation
    public function get geometryCenter():Vector
    public function set geometryCenter(value:Vector):void
m_bUseSingleContainerproperty 
protected var m_bUseSingleContainer:Boolean = true
m_nDepthproperty 
protected var m_nDepth:Number = 0
m_oContainerproperty 
protected var m_oContainer:Sprite
m_oGeomCenterproperty 
protected var m_oGeomCenter:Vector
useSingleContainerproperty 
useSingleContainer:Boolean  [write-only]

setter that allow user to change the way to render this object. set to true, the shape will be rendered into a single Sprite object, which is accessible through the container property. set to false, the container property does not target anything, but all the polygons will be rendered into their own dedidated container.

If true, this object renders itself on a single container ( Sprite ),
if false, each polygon is rendered on its own container.

Implementation
    public function set useSingleContainer(value:Boolean):void
Constructor detail
Shape3D()constructor
public function Shape3D(p_sName:String = "", p_oGeometry:Geometry3D = null, p_oAppearance:Appearance = null, p_bUseSingleContainer:Boolean = true)

Creates a 3D object

[Todo: some more explanations]

Parameters
p_sName:String (default = "") — A string identifier for this object
 
p_oGeometry:Geometry3D (default = null) — The geometry of this object
 
p_oAppearance:Appearance (default = null) — The appearance of this object. If no apperance is given, the DEFAULT_APPEARANCE will be applied.
 
p_bUseSingleContainer:Boolean (default = true) — Whether tis object should use a single container to draw on
Method detail
_onInteraction()method
protected function _onInteraction(p_oEvt:Event):voidParameters
p_oEvt:Event
clear()method 
public function clear():void

Clears the graphics object of this object's container.

The the graphics that were drawn on the Graphics object is erased, and the fill and line style settings are reset.

clone()method 
public function clone(p_sName:String = "", p_bKeepTransform:Boolean = false):Shape3D

This method returns a clone of this Shape3D. The current appearance will be applied, and the geometry is cloned (not referenced to curent one).

Parameters
p_sName:String (default = "") — The name of the new shape you are going to create
 
p_bKeepTransform:Boolean (default = false) — Boolean value which, if set to true, applies the current local transformations to the cloned shape. Default value is false.

Returns
Shape3D — The clone
cull()method 
public override function 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.

If this node and its children are not within the frustum, the node is set to cull and it would not be displayed.

The method also updates the bounding volumes to make the more accurate culling system possible.
First the bounding sphere is updated, and if intersecting, the bounding box is updated to perform the more precise culling.

[MANDATORY] The update method must be called first!

Parameters
p_oScene:Scene3D — The current scene
 
p_oFrustum:Frustum — The frustum of the current camera
 
p_oViewMatrix:Matrix4 — The view martix of the curren camera
 
p_bChanged:Boolean
destroy()method 
public override function destroy():void

Destroy this object and all its faces container object is removed, and graphics cleared. All polygons have their

display()method 
public function display(p_oScene:Scene3D, p_oContainer:Sprite = null):void

Performs a z-sorting and renders the objects visible polygons.

The method is called only if the object renders on a single container
- ( useSingleContainer = true ).

Parameters
p_oScene:Scene3D — The current scene
 
p_oContainer:Sprite (default = null) — The container to draw on
render()method 
public override function render(p_oScene:Scene3D, p_oCamera:Camera3D):void

Renders this 3D object.

Parameters
p_oScene:Scene3D — The current scene
 
p_oCamera:Camera3D — The current camera
swapCulling()method 
public function swapCulling():void

Changes the backface culling side.

When you want to display a cube and you are the cube, you see its external faces.
The internal faces are not drawn due to back face culling

In case you are inside the cube, by default Sandy's engine still doesn't draw the internal faces (because you should not be in there).

If you need to be only inside the cube, you can call this method to change which side is culled.
The faces will be visible only from the interior of the cube.

If you want to be both on the inside and the outside, you want to make the faces visible from on both sides.
In that case you just have to set enableBackFaceCulling to false.

toString()method 
public override function toString():String

Returns a string representation of this object

Returns
String — The fully qualified name of this object and its geometry
updateBoundingVolumes()method 
public function updateBoundingVolumes():void

Updates the bounding volumes of this object.