1 /**
2 * ...
3 * @author Matthew Casperson
4 */
5
6 package ;
7
8 import fr.seraf.wow.primitive.WParticle;
9 import sandy.primitive.Sphere;
10 import sandy.materials.Appearance;
11 import sandy.materials.attributes.LightAttributes;
12 import sandy.materials.attributes.MaterialAttributes;
13 import sandy.materials.attributes.LineAttributes;
14 import sandy.materials.ColorMaterial;
15 import sandy.materials.Material;
16 import fr.seraf.wow.primitive.WSphere;
17
18 class SpherePhysicsObject extends PhysicsObject
19 {
20 private var timeToReset:Float;
21
22 public function new(engineManager:EngineManager)
23 {
24 timeToReset = 10;
25
26 var sphere:Sphere = new Sphere( "" , 5 , 4 , 3);
27 var materialAttr:MaterialAttributes = new MaterialAttributes(
28 [new LineAttributes( 0.5 , 0x2111BB , 0.4 ) ,
29 new LightAttributes( true , 0.1)]);
30 var material:Material = new ColorMaterial( 0xFFCC33 , 1 , materialAttr );
31 material.lightingEnable = true;
32 var app:Appearance = new Appearance( material );
33 sphere.appearance = app;
34 sphere.useSingleContainer = false;
35
36 var wowSphere = new WSphere(0, 0, 0, 5 , false , 1 , 1 , 1);
37 wowSphere.elasticity = 0.75;
38 wowSphere.friction = 0;
39
40 super(engineManager, sphere, wowSphere);
41
42 setPosition();
43 }
44
45 private function setPosition():Void
46 {
47 var randomX = Math.random() * 40 - 20;
48 var randomY = Math.random() * 20 + 5;
49 var randomZ = Math.random() * 40 - 20 + 200;
50
51 wowParticle.px = randomX;
52 wowParticle.py = randomY;
53 wowParticle.pz = randomZ;
54 }
55
56 override public function enterFrame(dt:Float) : Void
57 {
58 super.enterFrame(dt);
59
60 timeToReset -= dt;
61 if (timeToReset <= 0)
62 {
63 timeToReset = 10;
64 setPosition();
65 }
66 }
67
68 }
Top