Packagesandy.core.data
Classpublic final class Polygon
ImplementsIDisplayable

Polygon's are the building blocks of visible 3D shapes.



Public Properties
 PropertyDefined by
  a : Vertex
Polygon
  aEdges : Array
[READ-ONLY] property.
Polygon
  aNeighboors : Array
[READ-ONLY] property Array of polygons that share an edge with the current polygon.
Polygon
  appearance : Appearance
The appearance of this polygon.
Polygon
  aUVCoord : Array
[READ-ONLY] property.
Polygon
  broadcaster : BubbleEventBroadcaster
[read-only] The broadcaster property.
Polygon
  caUVCoord : Array
[READ-ONLY] property.
Polygon
  container : Sprite
[read-only] The container for this polygon.
Polygon
  cvertices : Array
[READ-ONLY] property.
Polygon
  depth : Number
Polygon
  depthSorter : IDepthSorter
Polygon
  enableEvents : Boolean
Enables or disables object events for this polygon.
Polygon
  enableInteractivity : Boolean
Polygon
  hasAppearanceChanged : Boolean = false
States if the appearance of the polygon has changed since the previous rendering.
Polygon
  isClipped : Boolean = false
[READ-ONLY] property.
Polygon
  minZ : Number
Polygon
  m_nDepth : Number
Polygon
  normal : Vertex
[READ-ONLY] property.
Polygon
  POLYGON_MAP : Dictionary
[static] This property lists all the polygons.
Polygon
  scene : Scene3D
[READ-ONLY] property.
Polygon
  shape : Shape3D
[READ-ONLY] property.
Polygon
  uvBounds : Rectangle
[READ-ONLY] property.
Polygon
  vertexNormals : Array
[READ-ONLY] property.
Polygon
  vertices : Array
[READ-ONLY] property.
Polygon
  visible : Boolean
Is this face visible?.
Polygon
Protected Properties
 PropertyDefined by
  m_oContainer : Sprite
Polygon
  m_oEB : BubbleEventBroadcaster
Polygon
Public Methods
 MethodDefined by
  
Polygon(p_oOwner:Shape3D, p_geometry:Geometry3D, p_aVertexID:Array, p_aUVCoordsID:Array = null, p_nFaceNormalID:Number = 0, p_nEdgesID:uint = 0)
Creates a new polygon.
Polygon
  
addEventListener(p_sEvent:String, oL:*):void
Adds a listener for specifical event.
Polygon
  
clear():void
Clears the container of this polygon from graphics.
Polygon
  
clip(p_oFrustum:Frustum):Array
Returns an array containing the vertices, clipped by the camera frustum.
Polygon
  
clipFrontPlane(p_oFrustum:Frustum):Array
Perform a clipping against the near frustum plane.
Polygon
  
Polygon
  
Calculates and returns the normal vector of the polygon.
Polygon
  
destroy():void
Destroys the sprite attache to this polygon.
Polygon
  
display(p_oScene:Scene3D, p_oContainer:Sprite = null):void
Displays this polygon on its container if visible.
Polygon
  
get3DFrom2D(p_oScreenPoint:Point):Vector
Returns the real 3D position of the 2D screen position.
Polygon
  
getUVFrom2D(p_oScreenPoint:Point):UVCoord
Get the UVCoord under the 2D screen position after a mouse click or something The 2D position is usually coming from :
   var l_nClicX:Number = m_oScene.container.mouseX;
         var l_nClicY:Number = m_oScene.container.mouseY;
         
Polygon
  
precompute():void
Pre-compute several properties of the polygon in the same time.
Polygon
  
removeEventListener(p_sEvent:String, oL:*):void
Removes a listener for specifical event.
Polygon
  
swapCulling():void
Changes which side is the "normal" culling side.
Polygon
  
toString():String
Returns a string representing of this polygon.
Polygon
Protected Methods
 MethodDefined by
  
_onInteraction(p_oEvt:Event):void
Polygon
  
_onTextureInteraction(p_oEvt:Event = null):void
Polygon
  
_startMouseInteraction(e:MouseEvent = null):void
Polygon
  
_stopMouseInteraction(e:MouseEvent = null):void
Polygon
Public Constants
 ConstantDefined by
  id : uint
[READ-ONLY] property Unique polygon ID Number.
Polygon
Property detail
aproperty
public var a:Vertex
aEdgesproperty 
public var aEdges:Array

[READ-ONLY] property.

aNeighboorsproperty 
public var aNeighboors:Array

[READ-ONLY] property Array of polygons that share an edge with the current polygon.

appearanceproperty 
appearance:Appearance  [read-write]

The appearance of this polygon.

Implementation
    public function get appearance():Appearance
    public function set appearance(value:Appearance):void
aUVCoordproperty 
public var aUVCoord:Array

[READ-ONLY] property.

broadcasterproperty 
broadcaster:BubbleEventBroadcaster  [read-only]

The broadcaster property.

The broadcaster is the property used to send events to listeners.

Implementation
    public function get broadcaster():BubbleEventBroadcaster
caUVCoordproperty 
public var caUVCoord:Array

[READ-ONLY] property.

containerproperty 
container:Sprite  [read-only]

The container for this polygon.

Implementation
    public function get container():Sprite
cverticesproperty 
public var cvertices:Array

[READ-ONLY] property. Array of clipped vertices. Check isClipped property first to see if this array shall be containing the useful data or not.

depthproperty 
depth:Number  [read-write]Implementation
    public function get depth():Number
    public function set depth(value:Number):void
depthSorterproperty 
public var depthSorter:IDepthSorter
enableEventsproperty 
enableEvents:Boolean  [read-write]

Enables or disables object events for this polygon.

If a value of true is passed, the object events onPress, onRollOver and onRollOut are enabled.
. To use them, you have to add listeners for the events.

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

States if the appearance of the polygon has changed since the previous rendering. Often used to update the scene material manager. WARNING: Shall not be changed manually

isClippedproperty 
public var isClipped:Boolean = false

[READ-ONLY] property. Specify if the polygon has been clipped

minZproperty 
public var minZ:Number
m_nDepthproperty 
public var m_nDepth:Number
m_oContainerproperty 
protected var m_oContainer:Sprite
m_oEBproperty 
protected var m_oEB:BubbleEventBroadcaster
normalproperty 
public var normal:Vertex

[READ-ONLY] property.

POLYGON_MAPproperty 
public static var POLYGON_MAP:Dictionary

This property lists all the polygons. This is an helping property since it allows to retrieve a polygon instance from its unique ID. Polygon objects have an unique ID with myPolygon.id. Using : Polygon.POLYGON_MAP[myPolygon.id] returns myPolygon (for sure this example has no interesst except showing the use of the property.

sceneproperty 
public var scene:Scene3D

[READ-ONLY] property. Refers to the Scene3D the shape is linked to.

shapeproperty 
public var shape:Shape3D

[READ-ONLY] property. Link to the Shape3D instance this polygon is related too.

uvBoundsproperty 
public var uvBounds:Rectangle

[READ-ONLY] property. This property contains the texture bounds as a Rectangle.

vertexNormalsproperty 
public var vertexNormals:Array

[READ-ONLY] property.

verticesproperty 
public var vertices:Array

[READ-ONLY] property. Array of original vertices.

visibleproperty 
public var visible:Boolean

Is this face visible?. The method returns the visibility value pre computed after precompute method call. This getter shall be called afer the precompute call.

Constructor detail
Polygon()constructor
public function Polygon(p_oOwner:Shape3D, p_geometry:Geometry3D, p_aVertexID:Array, p_aUVCoordsID:Array = null, p_nFaceNormalID:Number = 0, p_nEdgesID:uint = 0)

Creates a new polygon.

Parameters
p_oOwner:Shape3D — The shape this polygon belongs to
 
p_geometry:Geometry3D — The geometry this polygon is part of
 
p_aVertexID:Array — The vertexID array of this polygon
 
p_aUVCoordsID:Array (default = null) — The UVCoordsID array of this polygon
 
p_nFaceNormalID:Number (default = 0) — The faceNormalID of this polygon
 
p_nEdgesID:uint (default = 0) — The edgesID of this polygon
Method detail
_onInteraction()method
protected function _onInteraction(p_oEvt:Event):voidParameters
p_oEvt:Event
_onTextureInteraction()method 
protected function _onTextureInteraction(p_oEvt:Event = null):voidParameters
p_oEvt:Event (default = null)
_startMouseInteraction()method 
protected function _startMouseInteraction(e:MouseEvent = null):voidParameters
e:MouseEvent (default = null)
_stopMouseInteraction()method 
protected function _stopMouseInteraction(e:MouseEvent = null):voidParameters
e:MouseEvent (default = null)
addEventListener()method 
public function addEventListener(p_sEvent:String, oL:*):void

Adds a listener for specifical event.

Parameters
p_sEvent:String — Name of the Event.
 
oL:* — Listener object.
clear()method 
public function clear():void

Clears the container of this polygon from graphics.

clip()method 
public function clip(p_oFrustum:Frustum):Array

Returns an array containing the vertices, clipped by the camera frustum.

Parameters
p_oFrustum:Frustum

Returns
Array — The array of clipped vertices
clipFrontPlane()method 
public function clipFrontPlane(p_oFrustum:Frustum):Array

Perform a clipping against the near frustum plane.

Parameters
p_oFrustum:Frustum

Returns
Array — The array of clipped vertices
createNormal()method 
public function createNormal():Vector

Returns
Vector
createTransformedNormal()method 
public function createTransformedNormal():Vector

Calculates and returns the normal vector of the polygon.

Returns
Vector — The normal vector
destroy()method 
public function destroy():void

Destroys the sprite attache to this polygon.

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

Displays this polygon on its container if visible.

Parameters
p_oScene:Scene3D — The current scene this polygon is rendered into
 
p_oContainer:Sprite (default = null) — The container to draw on
get3DFrom2D()method 
public function get3DFrom2D(p_oScreenPoint:Point):Vector

Returns the real 3D position of the 2D screen position. The 2D position is usually coming from :

   var l_nClicX:Number = m_oScene.container.mouseX;
         var l_nClicY:Number = m_oScene.container.mouseY;
         

Parameters
p_oScreenPoint:Point

Returns
Vector — the real 3D position which correspond to the intersection onto that polygone
getUVFrom2D()method 
public function getUVFrom2D(p_oScreenPoint:Point):UVCoord

Get the UVCoord under the 2D screen position after a mouse click or something The 2D position is usually coming from :

   var l_nClicX:Number = m_oScene.container.mouseX;
         var l_nClicY:Number = m_oScene.container.mouseY;
         

Parameters
p_oScreenPoint:Point

Returns
UVCoord — the UVCoord under the 2D screen point
precompute()method 
public function precompute():void

Pre-compute several properties of the polygon in the same time. List of the computed properties :

removeEventListener()method 
public function removeEventListener(p_sEvent:String, oL:*):void

Removes a listener for specifical event.

Parameters
p_sEvent:String — Name of the Event.
 
oL:* — Listener object.
swapCulling()method 
public function swapCulling():void

Changes which side is the "normal" culling side.

The method also swaps the front and back skins.

toString()method 
public function toString():String

Returns a string representing of this polygon.

Returns
String — The string representation.
Constant detail
idconstant
public const id:uint

[READ-ONLY] property Unique polygon ID Number.