Skip to content

Commit

Permalink
fix Away3dMesh bug
Browse files Browse the repository at this point in the history
  • Loading branch information
muzerly committed Dec 13, 2010
1 parent 125c780 commit 68742a8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
33 changes: 20 additions & 13 deletions fp10/examples/away3d/Away3DFlash3DPhysics.as
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/
[SWF(width="800", height="600", backgroundColor="#222266", frameRate="60")]
public class Away3DFlash3DPhysics extends Sprite

{
private var view:View3D;
private var mylight:PointLight3D;
Expand All @@ -48,7 +49,6 @@

public function Away3DFlash3DPhysics()
{

stage.addEventListener( KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener( KeyboardEvent.KEY_UP, keyUpHandler);
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
Expand All @@ -66,18 +66,20 @@
view.y = stage.stageHeight / 2;
addChild(view);

view.renderer = Renderer.CORRECT_Z_ORDER;

mylight = new PointLight3D();
view.scene.addChild(mylight);
view.scene.addLight(mylight);
mylight.ambient = 0.4;
mylight.y = 500;
mylight.z = -700;

view.camera.y = mylight.y;
view.camera.z = mylight.z;
view.camera.lookAt(new Vector3D());

physics = new Away3DPhysics(view, 8);

materia = new ShadingColorMaterial(0x77ee77);
//ground = physics.createGround({ material:this.materia, width:500, height:500 });
ground = physics.createCube( { material:this.materia, width:500, height:10, depth:500 } );
ground = physics.createCube( { material:this.materia, width:500, height:10, depth:500, segmentsW:2, segmentsH:1, segmentsD:2} );
ground.movable = false;
ground.friction = 0.2;
ground.restitution = 0.8;
Expand All @@ -93,7 +95,8 @@
ballBody[i].moveTo(new Vector3D( -100, 30 + (50 * i + 50), -100));
}

boxBody=new Vector.<RigidBody>();
boxBody = new Vector.<RigidBody>();
materia = new ShadingColorMaterial(0xeeee00);
for (i = 0; i < 6; i++)
{
boxBody[i] = physics.createCube({ material:this.materia, width:50, height:30, depth:40 });
Expand All @@ -111,10 +114,14 @@
capsuleBody[i].moveTo(new Vector3D(100, 10 + (80 * i + 80), -100));
physics.addBody(capsuleBody[i]);
}

view.camera.y = mylight.y;
view.camera.z = mylight.z;
view.camera.lookAt(physics.getMesh(ground).position);
}

private function clearBodies():void {
for each(var body:RigidBody in boxBody) {
view.scene.removeChild(physics.getMesh(body));
physics.engine.removeBody(body);
}
boxBody.splice(0, boxBody.length);
}

private function keyDownHandler(event:KeyboardEvent):void
Expand Down Expand Up @@ -143,6 +150,7 @@
case Keyboard.SPACE:
keyUp = true;
break;
break;
}
}

Expand All @@ -166,7 +174,7 @@
keyRight = false;
break;
case Keyboard.SPACE:
keyUp=false;
//keyUp=false;
}
}

Expand Down Expand Up @@ -219,7 +227,6 @@
{
ballBody[0].addWorldForce(new Vector3D(0, 50, 0), ballBody[0].currentState.position);
}

physics.engine.integrate(0.1);

resetBody();
Expand Down
Binary file modified fp10/examples/away3d/Away3DFlash3DPhysics.swf
Binary file not shown.
4 changes: 2 additions & 2 deletions fp10/examples/away3d/Away3DTerrainTest.as
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import away3d.containers.*;
import away3d.primitives.*;
import away3d.lights.PointLight3D;
import away3d.core.math.Number3D;
import away3d.core.base.Mesh;
import away3d.core.render.Renderer;
import away3d.materials.ShadingColorMaterial;
Expand Down Expand Up @@ -67,7 +66,8 @@
//view.renderer = Renderer.CORRECT_Z_ORDER;

mylight = new PointLight3D();
view.scene.addChild(mylight);
view.scene.addLight(mylight);
mylight.ambient = 0.4;
mylight.y = 900;

materia = new ShadingColorMaterial(0x77ee77);
Expand Down
Binary file modified fp10/examples/away3d/Away3DTerrainTest.swf
Binary file not shown.
1 change: 0 additions & 1 deletion fp10/src/jiglib/plugin/away3d/Away3dMesh.as
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package jiglib.plugin.away3d {

import jiglib.plugin.ISkin3D;
import away3d.core.base.Mesh;
import away3d.core.math.Number3D;

/**
* @author bartekd
Expand Down

0 comments on commit 68742a8

Please sign in to comment.