1. package
  2. {
  3. import away3d.primitives.Skybox;
  4. import jiglib.physics.RigidBody;
  5. import away3d.materials.WireframeMaterial;
  6. import jiglib.plugin.away3d.Away3dMesh;
  7. import away3d.core.math.Number3D;
  8. import mx.collections.ArrayCollection;
  9.  
  10. public class ApplicationManager extends BaseObject
  11. {
  12. protected var spheres:ArrayCollection = new ArrayCollection();
  13.  
  14. public function ApplicationManager()
  15. {
  16. super();
  17. }
  18.  
  19. public function startupApplicationManager(engineManager:EngineManager):ApplicationManager
  20. {
  21. super.startupBaseObject(engineManager);
  22.  
  23. for (var i:int = 0; i < 20; i++)
  24. {
  25. var sphere:RigidBody = this.engineManager.physics.createSphere({radius:15, segmentsW:6, segmentsH:6});
  26. sphere.x = 100 - Math.random() * 200;
  27. sphere.y = Math.random() * 500;
  28. sphere.z = 500 - Math.random() * 100;
  29. sphere.material.restitution = 2;
  30.  
  31. spheres.addItem(sphere);
  32.  
  33. // This is how to access the engine specific mesh/do3d
  34. this.engineManager.physics.getMesh(sphere).material = this.engineManager.MyResourceManager.MetalTex;
  35. }
  36.  
  37. var ground:RigidBody = this.engineManager.physics.createGround({segments:10, width:2000, height:2000}, -100);
  38. this.engineManager.physics.getMesh(ground).material = this.engineManager.MyResourceManager.GrassTex;
  39.  
  40. return this;
  41. }
  42.  
  43. public function reset():void
  44. {
  45. for each (var sphere:RigidBody in spheres)
  46. {
  47. sphere.x = 100 - Math.random() * 200;
  48. sphere.y = Math.random() * 500;
  49. sphere.z = 500 - Math.random() * 100;
  50. }
  51. }
  52.  
  53. public override function shutdown():void
  54. {
  55. super.shutdown();
  56. }
  57.  
  58. public override function enterFrame(dt:Number):void
  59. {
  60.  
  61. }
  62.  
  63. }
  64. }