ok, thanks! AWPCompundShape can contain more shapes now, but how can i make parent container invisible for collisions? Look at attachment.
fragment of code:
private function initObjects():void
{
createGround();
createSpheres();
}
private function createGround():void
{
var _groundShapeContainer:AWPCompoundShape = createGroundShape();
var mesh : Mesh;
var body : AWPRigidBody;
mesh = createMesh();
_view.scene.addChild(mesh);
body = new AWPRigidBody(_groundShapeContainer, mesh, 0);
body.position = new Vector3D(0,0,0);
_physics.addRigidBodyWithGroup(body, 1, 1);
body.position = new Vector3D( -400, 0, 0);
mesh.position = new Vector3D( -400, 0, 0);
trace("LISTA: ", _groundShapeContainer.children);
}
private function createGroundShape():AWPCompoundShape
{
var outsideContainer:AWPBoxShape = new AWPBoxShape(800, 300, 800);
var insideContainer :AWPBoxShape = new AWPBoxShape(400, 50, 800);
var mainContainer:AWPCompoundShape = new AWPCompoundShape();
mainContainer.addChildShape(outsideContainer, new Vector3D(0, 0, 0), new Vector3D(0, 0, 0));
mainContainer.addChildShape(insideContainer, new Vector3D(300, -500, 0), new Vector3D(0, 0, 0));
return mainContainer;
}
private function createMesh():Mesh
{
var mesh:Mesh = new Mesh();
var outsideContainer:WireframeCube = new WireframeCube(800, 300, 800, 0xFFFFFF, 2);
var insideContainer :WireframeCube = new WireframeCube(400, 50, 800, 0xFF0000, 1);
mesh.addChild(outsideContainer);
mesh.addChild(insideContainer);
insideContainer.position = new Vector3D(300, -500, 0);
return mesh;
}
private function createSpheres():void
{
var _sphereMesh:Mesh;
for (var i:int = 0; i < 20; i++)
{
_sphereMesh = new Sphere(_sphereMaterial, 25);
_view.scene.addChild(_sphereMesh);
_sphereShape = new AWPSphereShape(25);
var sphereRigid:AWPRigidBody = new AWPRigidBody(_sphereShape, _sphereMesh, 1);
sphereRigid.position = new Vector3D(0, 400 * i, 0);
sphereRigid.restitution = 0.1;
sphereRigid.linearDamping = 0.5;
//_physics.addRigidBody(sphereRigid);
_physics.addRigidBodyWithGroup(sphereRigid, 1, 1);
sphereRigid.addEventListener(AWPCollisionEvent.COLLISION_ADDED, collisionHandler, false, 0, true);
}
}
private function collisionHandler(e:AWPCollisionEvent):void
{
trace(e.collisionObject);
}