|
@@ -6,10 +6,6 @@ module BABYLON {
|
|
|
public world: any;
|
|
|
public name: string = "OimoJSPlugin";
|
|
|
|
|
|
- private _debugBoxMesh:Mesh;
|
|
|
- private _debugSphereMesh:Mesh;
|
|
|
- private _debugMaterial:StandardMaterial;
|
|
|
-
|
|
|
constructor(iterations?: number) {
|
|
|
this.world = new OIMO.World(1 / 60, 2, iterations, true);
|
|
|
this.world.worldscale(1);
|
|
@@ -412,59 +408,6 @@ module BABYLON {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private _getDebugMaterial(scene:Scene):Material{
|
|
|
- if(!this._debugMaterial){
|
|
|
- this._debugMaterial = new StandardMaterial('', scene);
|
|
|
- this._debugMaterial.wireframe = true;
|
|
|
- }
|
|
|
-
|
|
|
- return this._debugMaterial;
|
|
|
- }
|
|
|
-
|
|
|
- private _getDebugBoxMesh(scene:Scene):AbstractMesh{
|
|
|
- if(!this._debugBoxMesh){
|
|
|
- this._debugBoxMesh = MeshBuilder.CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
|
|
|
- this._debugBoxMesh.renderingGroupId = 1;
|
|
|
- this._debugBoxMesh.rotationQuaternion = Quaternion.Identity();
|
|
|
- this._debugBoxMesh.material = this._getDebugMaterial(scene);
|
|
|
- scene.removeMesh(this._debugBoxMesh);
|
|
|
- }
|
|
|
-
|
|
|
- return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
|
|
|
- }
|
|
|
-
|
|
|
- private _getDebugSphereMesh(scene:Scene):AbstractMesh{
|
|
|
- if(!this._debugSphereMesh){
|
|
|
- this._debugSphereMesh = MeshBuilder.CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
|
|
|
- this._debugSphereMesh.renderingGroupId = 1;
|
|
|
- this._debugSphereMesh.rotationQuaternion = Quaternion.Identity();
|
|
|
- this._debugSphereMesh.material = this._getDebugMaterial(scene);
|
|
|
- scene.removeMesh(this._debugSphereMesh);
|
|
|
- }
|
|
|
-
|
|
|
- return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
|
|
|
- }
|
|
|
-
|
|
|
- public getDebugMesh(impostor:PhysicsImpostor, scene:Scene):AbstractMesh{
|
|
|
- var body = impostor.physicsBody;
|
|
|
- var shape = body.shapes;
|
|
|
- var mesh:AbstractMesh;
|
|
|
-
|
|
|
- if (shape.halfWidth) {
|
|
|
- mesh = this._getDebugBoxMesh(scene);
|
|
|
- mesh.scaling.x = shape.halfWidth * 2;
|
|
|
- mesh.scaling.y = shape.halfHeight * 2;
|
|
|
- mesh.scaling.z = shape.halfDepth * 2;
|
|
|
- } else if(shape.radius){
|
|
|
- mesh = this._getDebugSphereMesh(scene);
|
|
|
- mesh.scaling.x = shape.radius * 2;
|
|
|
- mesh.scaling.y = shape.radius * 2;
|
|
|
- mesh.scaling.z = shape.radius * 2;
|
|
|
- }
|
|
|
-
|
|
|
- return mesh;
|
|
|
- }
|
|
|
-
|
|
|
public syncMeshWithImpostor(mesh:AbstractMesh, impostor:PhysicsImpostor){
|
|
|
var body = impostor.physicsBody;
|
|
|
|
|
@@ -478,16 +421,18 @@ module BABYLON {
|
|
|
mesh.rotationQuaternion.w = body.orientation.s;
|
|
|
}
|
|
|
|
|
|
+ public getRadius(impostor: PhysicsImpostor):number{
|
|
|
+ return impostor.physicsBody.shapes.radius;
|
|
|
+ }
|
|
|
+
|
|
|
+ public getBoxSizeToRef(impostor: PhysicsImpostor, result:Vector3):void{
|
|
|
+ var shape = impostor.physicsBody.shapes;
|
|
|
+ result.x = shape.halfWidth * 2;
|
|
|
+ result.y = shape.halfHeight * 2;
|
|
|
+ result.z = shape.halfDepth * 2;
|
|
|
+ }
|
|
|
+
|
|
|
public dispose() {
|
|
|
- if(this._debugBoxMesh){
|
|
|
- this._debugBoxMesh.dispose();
|
|
|
- }
|
|
|
- if(this._debugSphereMesh){
|
|
|
- this._debugSphereMesh.dispose();
|
|
|
- }
|
|
|
- if(this._debugMaterial){
|
|
|
- this._debugMaterial.dispose();
|
|
|
- }
|
|
|
this.world.clear();
|
|
|
}
|
|
|
}
|