Здравствуйте.
Кто работал с физическим движком Nape подскажите как реализовать создание физического тела из BitmapData. Нашел не один такой экземпл

Код AS3:
package code {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.GradientType;
import flash.display.Shape;
import flash.display.Sprite;
import flash.geom.Point;
import nape.space.Space;
import nape.geom.Vec2;
import nape.phys.Body;
import nape.phys.BodyType;
import nape.shape.Polygon;
import nape.geom.GeomPoly;
import nape.geom.AABB;
import nape.geom.GeomPolyList;
import nape.geom.MarchingSquares;
import starling.display.Image;
import starling.textures.Texture;
public class BitmapToBody {
[Embed(source= "../asset/user.png")]
private static const CLogo:Class;
[Embed(source= "../asset/user.png")]
private static const Donald:Class;
[Embed(source= "../asset/user.png")]
private static const Goofy:Class;
[Embed(source= "../asset/user.png")]
private static const Mickey:Class;
private var bitmap:BitmapData;
public function BitmapToBody(bmp:String)
{
var myBitmap:Bitmap;
switch (bmp) {
case "Donald":
myBitmap=new Donald();
break;
case "Goofy":
myBitmap=new Goofy();
break;
case "Mickey":
myBitmap=new Mickey();
break;
case "CLogo":
myBitmap=new CLogo();
break;
default:
}
bitmap =new BitmapData(myBitmap.width, myBitmap.height,true,1);
bitmap.draw(myBitmap);
}
public function NewBitmapToBody():Body
{
var body:Body = new Body();
var bounds:AABB = new AABB(0,0,bitmap.width,bitmap.height);
var threshold:uint = 0x00; var granularity:Vec2 = null;
var iso:Function = function iso(x:Number, y:Number):Number
{ //take 4 nearest pixels to interpolate linearlly
var ix:int = int(x);
var iy:int = int(y);
//clamp in-case of numerical inaccuracies
if (ix < 0) ix = 0;
if (iy < 0) iy = 0;
if (ix >= bitmap.width) ix = bitmap.width - 1;
if (iy >= bitmap.height) iy = bitmap.height - 1;
var fx:Number = x - ix;
var fy:Number = y - iy;
var a11:Number = threshold - (bitmap.getPixel32(ix,iy)>>>24);
var a12:Number = threshold - (bitmap.getPixel32(ix+1,iy)>>>24);
var a21:Number = threshold - (bitmap.getPixel32(ix,iy+1)>>>24);
var a22:Number = threshold - (bitmap.getPixel32(ix + 1, iy + 1) >>> 24);
var result:Number = a11 * (1 - fx) * (1 - fy) + a12 * fx * (1 - fy) + a21 * (1 - fx) * fy + a22 * fx * fy;
return result;
}
//iso surface is smooth from alpha channel + interpolation
//so less iterations are needed in extraction
var grain:Vec2 = (granularity==null) ? new Vec2(8,8) : granularity;
var polys:GeomPolyList = MarchingSquares.run(iso, bounds, grain, 1,null,true);
var qolysF:Function = function(qoly:GeomPoly):void
{
body.shapes.add(new Polygon(qoly));
}
var polysF:Function = function(poly:GeomPoly):void
{
var qolys:GeomPolyList = poly.convexDecomposition();
qolys.foreach( qolysF);
//body.shapes.add(new Polygon(poly));
}
polys.foreach( polysF );
//want to align body to it's centre of mass
//and also have graphic offset correctly
//easiest way is to wrap the graphic in another.
var anchor:Vec2 = body.localCOM.mul(-1);
body.translateShapes(anchor);
var img:Image = getStarlingGraphicObject();
//body.userData = img;
return body;
}
private function getStarlingGraphicObject(): Image {
var texture:Texture = Texture.fromBitmapData(bitmap);
var image:Image= new Image(texture);
image.pivotX=image.width/2;
image.pivotY=image.height/2;
return image;
}
}
}
Но FB подсвечивает ошибки

Код AS3:
var ix:int = Std._int(x); // не определённый метод
var iy:int = Std._int(y);// не определённый метод
poly.convex_decomposition(); // не определённый метод
var polys:GeomPolyList = MarchingSquares.run(iso, bounds, grain, 1,null,true); // неявное приведения значения типа Function к несоот. типу nape.geom:IsoFunction
незнаю с чем это связанно, может обновили сам движок переписал на

Код AS3:
var ix:int = int(x);
var iy:int = int(y);
poly.convexDecomposition();
но ничего это не дало.
Объект помещаю

Код AS3:
var b:BitmapToBody = new BitmapToBody();
var body:Body=b.test(); // демо построение
body.space = mySpace;