, Jr. Member
OK, was able to do this by hand via AwayBuilder to create simple geometries and line them up by eye. Is that the overall approach to physics, just need to get it close enough so that the body pretty much reacts the way we want?
Here’s my actual code (still not sure why it’s not falling over- but that’s a separate thread)
//getAWDAssetsFromLoader() is handled elsewhere really, keeps a reference to each asset as its loaded
//lightPicker, physicsWorld, scene are all elsewhere as well
private function init(ldr:Loader3D) {
var geom:PlaneGeometry;
var mesh:Mesh;
var mat:ColorMaterial;
var cylShape:AWPCylinderShape;
var boxShape:AWPBoxShape;
var coneShape:AWPConeShape;
var shapeContainer:AWPCompoundShape;
var body:AWPRigidBody;
var meshContainer:ObjectContainer3D = new ObjectContainer3D();
var assets:Array = getAWDAssetsFromLoader(ldr);
var obj:Object;
for each(obj in assets) {
if(obj is MaterialBase) {
if(obj is TextureMaterial) {
(obj as TextureMaterial).alpha = .3;
}
(obj as MaterialBase).lightPicker = lightPicker;
} else if(obj is Mesh) {
mesh = obj as Mesh;
}
}
mesh.rotationY = -18;
meshContainer.addChild(mesh);
//Physics
shapeContainer = new AWPCompoundShape();
cylShape = new AWPCylinderShape(12, 30);
boxShape = new AWPBoxShape(70,56,70);
coneShape = new AWPConeShape(35, 28);
//Flip it upside down
coneShape.localScaling = new Vector3D(1,-1,1,1);
shapeContainer.addChildShape(coneShape, new Vector3D(0,14,0,0));
shapeContainer.addChildShape(boxShape, new Vector3D(0,56,0,0));
shapeContainer.addChildShape(cylShape, new Vector3D(0,100,0,0));
body = new AWPRigidBody(shapeContainer, meshContainer, 10);
body.position = new Vector3D(0,100,0);
//body.restitution = .8;
body.friction = 100;
body.applyTorque(new Vector3D(0, 100, 0, 0));
physicsWorld.addRigidBody(body);
scene.addChild(meshContainer);
}