package starling.display {
import starling.textures.Texture;
import starling.styles.MeshStyle;
import starling.rendering.VertexDataFormat;
import starling.rendering.VertexData;
import starling.rendering.Painter;
import starling.rendering.IndexData;
import starling.geom.Polygon;
import openfl.geom.Rectangle;
import openfl.geom.Point;
/**
 *  The base class for all tangible (non-container) display objects, spawned up by a number
 *  *  of triangles.
 *  *
 *  *  <p>Since Starling uses Stage3D for rendering, all rendered objects must be constructed
 *  *  from triangles. A mesh stores the information of its triangles through VertexData and
 *  *  IndexData structures. The default format stores position, color and texture coordinates
 *  *  for each vertex.</p>
 *  *
 *  *  <p>How a mesh is rendered depends on its style. Per default, this is an instance
 *  *  of the <code>MeshStyle</code> base class; however, subclasses may extend its behavior
 *  *  to add support for color transformations, normal mapping, etc.</p>
 *  *
 *  *  @see MeshBatch
 *  *  @see starling.styles.MeshStyle
 *  *  @see starling.rendering.VertexData
 *  *  @see starling.rendering.IndexData
 *  
 * @externs
 */
public class Mesh extends starling.display.DisplayObject {
	/**
	 *  Creates a new mesh with the given vertices and indices.
	 *      *  If you don't pass a style, an instance of <code>MeshStyle</code> will be created
	 *      *  for you. Note that the format of the vertex data will be matched to the
	 *      *  given style right away. 
	 */
	public function Mesh(vertexData:starling.rendering.VertexData, indexData:starling.rendering.IndexData, style:starling.styles.MeshStyle = undefined) {
		super();
	}
	/**
	 *  Creates a new instance of the current default MeshStyle. Internally, this method
	 *      *  calls either the <code>defaultStyleFactory</code> or (if no factory has been assigned)
	 *      *  instantiates <code>defaultStyle</code>.
	 *      
	 */
	public static function createDefaultStyle(instance:starling.display.Mesh = undefined):starling.styles.MeshStyle { return null; }
	/**
	 *  The default style used for meshes if no specific style is provided. The default is
	 *      *  <code>starling.rendering.MeshStyle</code>, and any assigned class must be a subclass
	 *      *  of the same. 
	 */
	public static function get defaultStyle():Class { return null; }
	public static function set defaultStyle(value:Class):void {}
	/**
	 *  A factory method that is used to create the 'MeshStyle' for a mesh if no specific
	 *      *  style is provided. That's useful if you are creating a hierarchy of objects, all
	 *      *  of which need to have a certain style. Different to the <code>defaultStyle</code>
	 *      *  property, this method allows plugging in custom logic and passing arguments to the
	 *      *  constructor. Return <code>null</code> to fall back to the default behavior (i.e.
	 *      *  to instantiate <code>defaultStyle</code>). The <code>mesh</code>-parameter is optional
	 *      *  and may be omitted.
	 *      *
	 *      *  <listing>
	 *      *  Mesh.defaultStyleFactory = function(mesh:Mesh):MeshStyle
	 *      *  {
	 *      *      return new ColorizeMeshStyle(Math.random() * 0xffffff);
	 *      *  }</listing>
	 *      
	 */
	public static function get defaultStyleFactory():Function { return null; }
	public static function set defaultStyleFactory(value:Function):void {}
	/**
	 *  Creates a mesh from the specified polygon.
	 *      *  Vertex positions and indices will be set up according to the polygon;
	 *      *  any other vertex attributes (e.g. texture coordinates) need to be set up manually.
	 *      
	 */
	public static function fromPolygon(polygon:starling.geom.Polygon, style:starling.styles.MeshStyle = undefined):starling.display.Mesh { return null; }
	/**
	 *  @inheritDoc 
	 */
	override public function dispose():void {}
	/**
	 *  @inheritDoc 
	 */
	override public function hitTest(localPoint:openfl.geom.Point):starling.display.DisplayObject { return null; }
	/**
	 *  @inheritDoc 
	 */
	override public function getBounds(targetSpace:starling.display.DisplayObject, out:openfl.geom.Rectangle = undefined):openfl.geom.Rectangle { return null; }
	/**
	 *  @inheritDoc 
	 */
	override public function render(painter:starling.rendering.Painter):void {}
	/**
	 *  Sets the style that is used to render the mesh. Styles (which are always subclasses of
	 *      *  <code>MeshStyle</code>) provide a means to completely modify the way a mesh is rendered.
	 *      *  For example, they may add support for color transformations or normal mapping.
	 *      *
	 *      *  <p>When assigning a new style, the vertex format will be changed to fit it.
	 *      *  Do not use the same style instance on multiple objects! Instead, make use of
	 *      *  <code>style.clone()</code> to assign an identical style to multiple meshes.</p>
	 *      *
	 *      *  @param meshStyle             the style to assign. If <code>null</code>, the default
	 *      *                               style will be created.
	 *      *  @param mergeWithPredecessor  if enabled, all attributes of the previous style will be
	 *      *                               be copied to the new one, if possible.
	 *      *  @see #defaultStyle
	 *      *  @see #defaultStyleFactory
	 *      
	 */
	public function setStyle(meshStyle:starling.styles.MeshStyle = undefined, mergeWithPredecessor:Boolean = undefined):void {}
	/**
	 *  This method is called whenever the mesh's vertex data was changed.
	 *      *  The base implementation simply forwards to <code>setRequiresRedraw</code>. 
	 */
	public function setVertexDataChanged():void {}
	/**
	 *  This method is called whenever the mesh's index data was changed.
	 *      *  The base implementation simply forwards to <code>setRequiresRedraw</code>. 
	 */
	public function setIndexDataChanged():void {}
	/**
	 *  The position of the vertex at the specified index, in the mesh's local coordinate
	 *      *  system.
	 *      *
	 *      *  <p>Only modify the position of a vertex if you know exactly what you're doing, as
	 *      *  some classes might not work correctly when their vertices are moved. E.g. the
	 *      *  <code>Quad</code> class expects its vertices to spawn up a perfectly rectangular
	 *      *  area; some of its optimized methods won't work correctly if that premise is no longer
	 *      *  fulfilled or the original bounds change.</p>
	 *      
	 */
	public function getVertexPosition(vertexID:int, out:openfl.geom.Point = undefined):openfl.geom.Point { return null; }
	public function setVertexPosition(vertexID:int, x:Number, y:Number):void {}
	/**
	 *  Returns the alpha value of the vertex at the specified index. 
	 */
	public function getVertexAlpha(vertexID:int):Number { return 0; }
	/**
	 *  Sets the alpha value of the vertex at the specified index to a certain value. 
	 */
	public function setVertexAlpha(vertexID:int, alpha:Number):void {}
	/**
	 *  Returns the RGB color of the vertex at the specified index. 
	 */
	public function getVertexColor(vertexID:int):int { return 0; }
	/**
	 *  Sets the RGB color of the vertex at the specified index to a certain value. 
	 */
	public function setVertexColor(vertexID:int, color:int):void {}
	/**
	 *  Returns the texture coordinates of the vertex at the specified index. 
	 */
	public function getTexCoords(vertexID:int, out:openfl.geom.Point = undefined):openfl.geom.Point { return null; }
	/**
	 *  Sets the texture coordinates of the vertex at the specified index to the given values. 
	 */
	public function setTexCoords(vertexID:int, u:Number, v:Number):void {}
	/**
	 *  The style that is used to render the mesh. Styles (which are always subclasses of
	 *      *  <code>MeshStyle</code>) provide a means to completely modify the way a mesh is rendered.
	 *      *  For example, they may add support for color transformations or normal mapping.
	 *      *  Beware: a style instance may only be used on one mesh at a time.
	 *      *
	 *      *  @default MeshStyle
	 *      *  @see #setStyle()
	 *      
	 */
	public function get style():starling.styles.MeshStyle { return null; }
	public function set style(value:starling.styles.MeshStyle):void {}
	/**
	 *  The texture that is mapped to the mesh (or <code>null</code>, if there is none). 
	 */
	public function get texture():starling.textures.Texture { return null; }
	public function set texture(value:starling.textures.Texture):void {}
	/**
	 *  Changes the color of all vertices to the same value.
	 *      *  The getter simply returns the color of the first vertex. 
	 */
	public function get color():int { return 0; }
	public function set color(value:int):void {}
	/**
	 *  The smoothing filter that is used for the texture.
	 *      *  @default bilinear 
	 */
	public function get textureSmoothing():String { return null; }
	public function set textureSmoothing(value:String):void {}
	/**
	 *  Indicates if pixels at the edges will be repeated or clamped. Only works for
	 *      *  power-of-two textures; for a solution that works with all kinds of textures,
	 *      *  see <code>Image.tileGrid</code>. @default false 
	 */
	public function get textureRepeat():Boolean { return false; }
	public function set textureRepeat(value:Boolean):void {}
	/**
	 *  Controls whether or not the instance snaps to the nearest pixel. This can prevent the
	 *      *  object from looking blurry when it's not exactly aligned with the pixels of the screen.
	 *      *  @default false 
	 */
	public function get pixelSnapping():Boolean { return false; }
	public function set pixelSnapping(value:Boolean):void {}
	/**
	 *  The total number of vertices in the mesh. 
	 */
	public function get numVertices():int { return 0; }
	/**
	 *  The total number of indices referencing vertices. 
	 */
	public function get numIndices():int { return 0; }
	/**
	 *  The total number of triangles in this mesh.
	 *      *  (In other words: the number of indices divided by three.) 
	 */
	public function get numTriangles():int { return 0; }
	/**
	 *  The format used to store the vertices. 
	 */
	public function get vertexFormat():starling.rendering.VertexDataFormat { return null; }
}
}
