Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

update examples

  • Loading branch information...
commit d71b73df042aad579f6366aef7d5d59b3bbdaf92 1 parent e7cd5ba
@muzerly muzerly authored
View
9 src/BasicTest.as
@@ -68,15 +68,10 @@ package {
_view.scene.addChild(ground);
// create ground shape and rigidbody
- var groundShape : AWPStaticPlaneShape = new AWPStaticPlaneShape(new Vector3D(0, 0, -1));
+ var groundShape : AWPStaticPlaneShape = new AWPStaticPlaneShape(new Vector3D(0, 1, 0));
var groundRigidbody : AWPRigidBody = new AWPRigidBody(groundShape, ground, 0);
_physicsWorld.addRigidBody(groundRigidbody);
- // set ground rotation
- var rot : Matrix3D = new Matrix3D();
- rot.appendRotation(90, new Vector3D(1, 0, 0));
- groundRigidbody.rotation = rot;
-
// create a wall
var wall : Cube = new Cube(material, 20000, 2000, 100);
_view.scene.addChild(wall);
@@ -143,7 +138,7 @@ package {
private function onMouseUp(event : MouseEvent3D) : void {
var pos : Vector3D = _view.camera.position;
- var mpos : Vector3D = new Vector3D(event.localX, event.localZ, event.localY);
+ var mpos : Vector3D = new Vector3D(event.localX, event.localY, event.localZ);
var impulse : Vector3D = mpos.subtract(pos);
impulse.normalize();
View
4 src/BvhTriangleMeshCarTest.as
@@ -69,7 +69,7 @@ package {
_loader.load(new URLRequest('../assets/scene.obj'), new OBJParser());
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onSceneResourceComplete);
- // load car model
+ //load car model
_loader = new Loader3D();
_loader.load(new URLRequest('../assets/car.obj'), new OBJParser());
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onCarResourceComplete);
@@ -90,7 +90,7 @@ package {
sceneMesh.material = materia;
// create triangle mesh shape
- var sceneShape : AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape(sceneMesh);
+ var sceneShape : AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape(sceneMesh.geometry);
var sceneBody : AWPRigidBody = new AWPRigidBody(sceneShape, sceneMesh, 0);
physicsWorld.addRigidBody(sceneBody);
View
5 src/CharacterDemo.as
@@ -17,6 +17,7 @@ package {
import away3d.loaders.parsers.OBJParser;
import away3d.materials.BitmapMaterial;
import away3d.materials.ColorMaterial;
+ import away3d.primitives.Capsule;
import away3d.primitives.Cube;
import away3d.primitives.Cylinder;
@@ -125,7 +126,7 @@ package {
//use to test bounding shape
var color:ColorMaterial=new ColorMaterial(0xffff00,0.4);
color.lights=[_light];
- var testMesh:Cylinder=new Cylinder(color,300,300,500);
+ var testMesh:Capsule=new Capsule(color,300,500);
container.addChild(testMesh);
// create character shape and controller
@@ -174,7 +175,7 @@ package {
sceneMesh.material = materia;
// create triangle mesh shape
- var sceneShape : AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape(sceneMesh);
+ var sceneShape : AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape(sceneMesh.geometry);
var sceneBody : AWPRigidBody = new AWPRigidBody(sceneShape, sceneMesh, 0);
physicsWorld.addRigidBody(sceneBody);
View
7 src/CollisionFilterTest.as
@@ -78,16 +78,11 @@ package {
_view.scene.addChild(ground);
// create ground shape and rigidbody
- var groundShape : AWPStaticPlaneShape = new AWPStaticPlaneShape(new Vector3D(0, 0, -1));
+ var groundShape : AWPStaticPlaneShape = new AWPStaticPlaneShape(new Vector3D(0, 1, 0));
var groundRigidbody : AWPRigidBody = new AWPRigidBody(groundShape, ground, 0);
// make ground collision enabled with other all rigidbodies
physicsWorld.addRigidBodyWithGroup(groundRigidbody, collsionGround, collisionAll);
- // set ground rotation
- var rot : Matrix3D = new Matrix3D();
- rot.appendRotation(90, new Vector3D(1, 0, 0));
- groundRigidbody.rotation = rot;
-
material = new ColorMaterial(0xfc6a11);
material.lights = [_light];
View
9 src/CompoundShapeTest.as
@@ -65,15 +65,10 @@ package {
_view.scene.addChild(ground);
// create ground shape and rigidbody
- var groundShape : AWPStaticPlaneShape = new AWPStaticPlaneShape(new Vector3D(0, 0, -1));
+ var groundShape : AWPStaticPlaneShape = new AWPStaticPlaneShape(new Vector3D(0, 1, 0));
var groundRigidbody : AWPRigidBody = new AWPRigidBody(groundShape, ground, 0);
physicsWorld.addRigidBody(groundRigidbody);
- // set ground rotation
- var rot : Matrix3D = new Matrix3D();
- rot.appendRotation(90, new Vector3D(1, 0, 0));
- groundRigidbody.rotation = rot;
-
// create a wall
var wall : Cube = new Cube(material, 20000, 5000, 100);
_view.scene.addChild(wall);
@@ -154,7 +149,7 @@ package {
private function onMouseUp(event : MouseEvent3D) : void {
var pos : Vector3D = _view.camera.position;
- var mpos : Vector3D = new Vector3D(event.localX, event.localZ, event.localY);
+ var mpos : Vector3D = new Vector3D(event.localX, event.localY, event.localZ);
var impulse : Vector3D = mpos.subtract(pos);
impulse.normalize();
View
11 src/ConstraintTest.as
@@ -71,15 +71,10 @@ package {
_view.scene.addChild(ground);
// create ground shape and rigidbody
- var groundShape : AWPStaticPlaneShape = new AWPStaticPlaneShape(new Vector3D(0, 0, -1));
+ var groundShape : AWPStaticPlaneShape = new AWPStaticPlaneShape(new Vector3D(0, 1, 0));
var groundRigidbody : AWPRigidBody = new AWPRigidBody(groundShape, ground, 0);
physicsWorld.addRigidBody(groundRigidbody);
- // set ground rotation
- var rot : Matrix3D = new Matrix3D();
- rot.appendRotation(90, new Vector3D(1, 0, 0));
- groundRigidbody.rotation = rot;
-
material = new ColorMaterial(0xfc6a11);
material.lights = [_light];
@@ -139,7 +134,7 @@ package {
var doorHinge : AWPHingeConstraint = new AWPHingeConstraint(currBody, new Vector3D(-250, 0, 0), new Vector3D(0, 1, 0));
doorHinge.setLimit(-Math.PI / 4, Math.PI / 4);
- // doorHinge.setAngularMotor(true, 10, 20);
+ // doorHinge.setAngularMotor(true, 100, 20);
physicsWorld.addConstraint(doorHinge);
// create a slider use AWPGeneric6DofConstraint
@@ -205,7 +200,7 @@ package {
private function onMouseUp(event : MouseEvent3D) : void {
var pos : Vector3D = _view.camera.position;
- var mpos : Vector3D = new Vector3D(event.localX, event.localZ, event.localY);
+ var mpos : Vector3D = new Vector3D(event.localX, event.localY, event.localZ);
var impulse : Vector3D = mpos.subtract(pos);
impulse.normalize();
View
4 src/ConvexHullShapeTest.as
@@ -103,7 +103,7 @@ package {
model.geometry.scale(300);
model.material = materia;
- var shape:AWPConvexHullShape = new AWPConvexHullShape(model);
+ var shape:AWPConvexHullShape = new AWPConvexHullShape(model.geometry);
var skin:Mesh;
var body:AWPRigidBody;
for (var i:int = 0; i < 20; i++ ) {
@@ -111,7 +111,7 @@ package {
_view.scene.addChild(skin);
body = new AWPRigidBody(shape, skin, 1);
body.friction=0.9;
- body.position = new Vector3D(0, 300 + 300 * i, 0);
+ body.position = new Vector3D(0, 1000 + 300 * i, 0);
_physicsWorld.addRigidBody(body);
}
}
View
11 src/GravityTest.as
@@ -9,6 +9,7 @@ package {
import away3d.primitives.Cube;
import away3d.primitives.Cylinder;
import away3d.primitives.Plane;
+ import flash.geom.Matrix3D;
import awayphysics.collision.shapes.AWPBoxShape;
import awayphysics.collision.shapes.AWPConeShape;
@@ -68,9 +69,13 @@ package {
_view.scene.addChild(ground);
// create ground shape and rigidbody
- var groundShape : AWPStaticPlaneShape = new AWPStaticPlaneShape(new Vector3D(0, 0, -1));
+ var groundShape : AWPStaticPlaneShape = new AWPStaticPlaneShape(new Vector3D(0, 1, 0));
var groundRigidbody : AWPRigidBody = new AWPRigidBody(groundShape, ground, 0);
physicsWorld.addRigidBody(groundRigidbody);
+
+ var rot :Matrix3D = new Matrix3D();
+ rot.appendRotation(-90, new Vector3D(1, 0, 0));
+ groundRigidbody.rotation = rot;
material = new ColorMaterial(0xe28313);
material.lights = [_light];
@@ -116,7 +121,7 @@ package {
private function onMouseDown(event : MouseEvent3D) : void {
isMouseDown = true;
- currMousePos = new Vector3D(event.localX, event.localY, -600);
+ currMousePos = new Vector3D(event.localX, event.localZ, -600);
this.addEventListener(Event.ENTER_FRAME, handleGravity);
}
@@ -142,7 +147,7 @@ package {
private function onMouseMove(event : MouseEvent3D) : void {
if (isMouseDown) {
- currMousePos = new Vector3D(event.localX, event.localY, -600);
+ currMousePos = new Vector3D(event.localX, event.localZ, -600);
}
}
View
8 src/Main.as
@@ -14,8 +14,7 @@ package {
// Setting, change _selectedDemo to 0 till 8
// 0 = Basictest, 1 = BasicStressTest, 2=Gravity, 3=compoundshape,4= collisionfilter
// 5= constraint, 6= vehicle terrain, 7= character walk demo, 8 = bvhTriangleMeshCar
- // 9= convexHullShapeTest
- private var _selectedDemo : int = 9;
+ private var _selectedDemo : int = 6;
// private var _totalDemos : int = 8;
private var _currentDemo : Sprite;
@@ -79,11 +78,6 @@ package {
this.addChild(bvhTriangleMeshCarTest);
_currentDemo = bvhTriangleMeshCarTest;
break;
- case 9:
- var convexHullShapeTest: ConvexHullShapeTest = new ConvexHullShapeTest();
- this.addChild(convexHullShapeTest);
- _currentDemo = convexHullShapeTest;
- break;
}
}
View
30 src/VehicleTerrainTest.as
@@ -16,11 +16,7 @@ package {
import awayphysics.extend.AWPTerrain;
import awayphysics.collision.dispatch.AWPCollisionObject;
- import awayphysics.collision.shapes.AWPBoxShape;
- import awayphysics.collision.shapes.AWPCompoundShape;
- import awayphysics.collision.shapes.AWPConeShape;
- import awayphysics.collision.shapes.AWPCylinderShape;
- import awayphysics.collision.shapes.AWPHeightfieldTerrainShape;
+ import awayphysics.collision.shapes.*;
import awayphysics.dynamics.AWPDynamicsWorld;
import awayphysics.dynamics.AWPRigidBody;
import awayphysics.dynamics.vehicle.AWPRaycastVehicle;
@@ -86,7 +82,7 @@ package {
_light.y = 5000;
_view.scene.addChild(_light);
- _view.camera.lens.far = 20000;
+ _view.camera.lens.far = 100000;
_view.camera.y = 2000;
_view.camera.z = -2000;
_view.camera.rotationX = 40;
@@ -110,7 +106,7 @@ package {
// create the terrain mesh
var terrainBMD : Bitmap = new HeightMap();
- var terrain : AWPTerrain = new AWPTerrain(bmaterial, terrainBMD.bitmapData, 50000, 1200, 50000, 60, 60, 1200, 0, false);
+ var terrain : AWPTerrain = new AWPTerrain(bmaterial, terrainBMD.bitmapData, 50000, 2000, 50000, 60, 60, 2000, 0, false);
_view.scene.addChild(terrain);
// create the terrain shape and rigidbody
@@ -156,11 +152,11 @@ package {
carMaterial = new BitmapMaterial(new CarSkin().bitmapData);
carMaterial.lights = [_light];
- // load car model
+ //load car model
var _loader : Loader3D = new Loader3D();
_loader.load(new URLRequest('../assets/car.obj'), new OBJParser());
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onCarResourceComplete);
-
+
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
stage.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
@@ -184,7 +180,7 @@ package {
// carBody.friction = 0.95;
carBody.linearDamping = 0.1;
carBody.angularDamping = 0.1;
- carBody.position = new Vector3D(0, 1000, 0);
+ carBody.position = new Vector3D(0, 1500, 0);
physicsWorld.addRigidBody(carBody);
// create vehicle
@@ -213,20 +209,6 @@ package {
}
}
- /*
- // create chassis mesh, just use to test
- private function createCarMesh(material:ColorMaterial):Mesh {
- var mesh:Mesh = new Mesh();
-
- var child1:Cube = new Cube(material, 260, 60, 570);
- var child2:Cube = new Cube(material, 240, 70, 300);
- child1.position = new Vector3D( 0, -20, 0);
- child2.position = new Vector3D( 0, 30, -30);
- mesh.addChild(child1);
- mesh.addChild(child2);
-
- return mesh;
- }*/
// create chassis shape
private function createCarShape() : AWPCompoundShape {
var boxShape1 : AWPBoxShape = new AWPBoxShape(260, 60, 570);
Please sign in to comment.
Something went wrong with that request. Please try again.