add Physics3DComponent support new

This commit is contained in:
jianglong0156 2015-07-27 14:26:50 +08:00
parent 4005ef6588
commit 1be5981d6a
6 changed files with 32 additions and 17 deletions

View File

@ -324,4 +324,19 @@ jsb.Skybox.prototype._ctor = function(positive_x, negative_x, positive_y, negati
{
throw new Error("error arguments");
}
}
jsb.DirectionLight.prototype._ctor = function(direction, color){
this.setDirection(direction);
this.setColor(color);
}
jsb.AmbientLight.prototype._ctor = function(color){
this.setColor(color);
}
jsb.Physics3DComponent.prototype._ctor = function(physicsObj, translateInPhysics = cc.math.vec3(), rotInPhsyics = new cc.math.Quaternion()){
this.init();
this.setPhysics3DObject(physicsObj);
this.setTransformInPhysics(translateInPhysics, rotInPhsyics);
}

View File

@ -209,12 +209,12 @@ var LightTest = LightTestDemo.extend({
},
addLights:function(){
this._ambientLight = jsb.AmbientLight.create(cc.color(200, 200, 200));
this._ambientLight = new jsb.AmbientLight(cc.color(200, 200, 200));
this._ambientLight.setEnabled(true);
this.addChild(this._ambientLight);
this._ambientLight.setCameraMask(2);
this._directionalLight = jsb.DirectionLight.create(cc.math.vec3(-1, -1, 0), cc.color(200, 200, 200));
this._directionalLight = new jsb.DirectionLight(cc.math.vec3(-1, -1, 0), cc.color(200, 200, 200));
this._directionalLight.setEnabled(false);
this.addChild(this._directionalLight);
this._directionalLight.setCameraMask(2);

View File

@ -169,10 +169,10 @@ var Material_setTechnique = MaterialSystemTestDemo.extend({
sprite.setMaterial(mat);
//lights
var light1 = jsb.AmbientLight.create(cc.color.RED);
var light1 = new jsb.AmbientLight(cc.color.RED);
this.addChild(light1);
var light2 = jsb.DirectionLight.create(cc.math.vec3(-1, 1, 0), cc.color.GREEN);
var light2 = new jsb.DirectionLight(cc.math.vec3(-1, 1, 0), cc.color.GREEN);
this.addChild(light2);
sprite.runAction(cc.rotateBy(5, cc.math.vec3(30, 60, 270)).repeatForever());

View File

@ -77,7 +77,7 @@ var NavMeshBaseTestDemo = NavMeshTestScene.extend({
rbDes.mass = 0;
rbDes.shape = jsb.Physics3DShape.createMesh(trianglesList, trianglesList.length/3);
var rigidBody = jsb.Physics3DRigidBody.create(rbDes);
var component = jsb.Physics3DComponent.create(rigidBody);
var component = new jsb.Physics3DComponent(rigidBody);
var sprite = jsb.Sprite3D.create("NavMesh/scene.obj");
sprite.addComponent(component);
sprite.setCameraMask(cc.CameraFlag.USER1);
@ -90,11 +90,11 @@ var NavMeshBaseTestDemo = NavMeshTestScene.extend({
physicsScene.setNavMesh(navMesh);
physicsScene.setNavMeshDebugCamera(this._camera);
var ambientLight = jsb.AmbientLight.create(cc.color(64, 64, 64));
var ambientLight = new jsb.AmbientLight(cc.color(64, 64, 64));
ambientLight.setCameraMask(cc.CameraFlag.USER1);
this.addChild(ambientLight);
var dirLight = jsb.DirectionLight.create(cc.math.vec3(1.2, -1.1, 0.5), cc.color(255, 255, 255));
var dirLight = new jsb.DirectionLight(cc.math.vec3(1.2, -1.1, 0.5), cc.color(255, 255, 255));
dirLight.setCameraMask(cc.CameraFlag.USER1);
this.addChild(dirLight);
},

View File

@ -304,7 +304,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
var rigidBody = jsb.Physics3DRigidBody.create(rbDes);
var quat = cc.math.quaternion(cc.math.vec3(0, 1, 0), cc.degreesToRadians(180));
var component = jsb.Physics3DComponent.create(rigidBody, cc.math.vec3(0, -3, 0), quat);
var component = new jsb.Physics3DComponent(rigidBody, cc.math.vec3(0, -3, 0), quat);
var sprite = new jsb.Sprite3D("Sprite3DTest/orc.c3b");
sprite.addComponent(component);
@ -326,7 +326,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
rbDes.mass = 1;
rbDes.shape = jsb.Physics3DShape.createBox(cc.math.vec3(8, 8, 1));
rigidBody = jsb.Physics3DRigidBody.create(rbDes);
component = jsb.Physics3DComponent.create(rigidBody);
component = new jsb.Physics3DComponent(rigidBody);
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
sprite.setTexture("Sprite3DTest/plane.png");
sprite.setScaleX(8);
@ -344,7 +344,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
rbDes.mass = 1;
rbDes.shape = jsb.Physics3DShape.createBox(cc.math.vec3(3, 2, 3));
rigidBody = jsb.Physics3DRigidBody.create(rbDes);
component = jsb.Physics3DComponent.create(rigidBody);
component = new jsb.Physics3DComponent(rigidBody);
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
sprite.setTexture("Sprite3DTest/plane.png");
sprite.setScaleX(3);
@ -359,7 +359,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
rbDes.mass = 0;
rbDes.shape = jsb.Physics3DShape.createBox(cc.math.vec3(3, 3, 3));
var rigidBodyB = jsb.Physics3DRigidBody.create(rbDes);
component = jsb.Physics3DComponent.create(rigidBodyB);
component = new jsb.Physics3DComponent(rigidBodyB);
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
sprite.setTexture("Sprite3DTest/plane.png");
sprite.setScale(3);
@ -380,7 +380,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
rbDes.mass = 1;
rbDes.shape = jsb.Physics3DShape.createBox(cc.math.vec3(3, 3, 3));
rigidBody = jsb.Physics3DRigidBody.create(rbDes);
component = jsb.Physics3DComponent.create(rigidBody);
component = new jsb.Physics3DComponent(rigidBody);
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
sprite.setTexture("Sprite3DTest/plane.png");
sprite.setScale(3);
@ -399,7 +399,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
rbDes.mass = 1;
rbDes.shape = jsb.Physics3DShape.createBox(cc.math.vec3(3, 3, 3));
rigidBody = jsb.Physics3DRigidBody.create(rbDes);
component = jsb.Physics3DComponent.create(rigidBody);
component = new jsb.Physics3DComponent(rigidBody);
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
sprite.setTexture("Sprite3DTest/plane.png");
sprite.setScale(3);
@ -571,7 +571,7 @@ var Physics3DCollisionCallbackDemo = Physics3DTestDemo.extend({
rbDes.shape = jsb.Physics3DShape.createMesh(trianglesList, trianglesList.length/3);
var rigidBody = jsb.Physics3DRigidBody.create(rbDes);
var component = jsb.Physics3DComponent.create(rigidBody);
var component = new jsb.Physics3DComponent(rigidBody);
var sprite = new jsb.Sprite3D("Sprite3DTest/boss.c3b");
sprite.addComponent(component);
sprite.setRotation3D(cc.math.vec3(-90, 0, 0));
@ -634,7 +634,7 @@ var Physics3DTerrainDemo = Physics3DTestDemo.extend({
var size = terrain.getTerrainSize();
rbDes.shape = jsb.Physics3DShape.createHeightfield(size.width, size.height, heightData, 1.0, terrain.getMinHeight(), terrain.getMaxHeight(), true, false, true);
var rigidBody = jsb.Physics3DRigidBody.create(rbDes);
var component = jsb.Physics3DComponent.create(rigidBody);
var component = new jsb.Physics3DComponent(rigidBody);
terrain.addComponent(component);
component.syncNodeToPhysics();
component.setSyncFlag(jsb.Physics3DComponent.PhysicsSyncFlag.NONE);
@ -672,7 +672,7 @@ var Physics3DTerrainDemo = Physics3DTestDemo.extend({
rbDes.mass = 0;
rbDes.shape = jsb.Physics3DShape.createMesh(trianglesList, trianglesList.length/3);
rigidBody = jsb.Physics3DRigidBody.create(rbDes);
component = jsb.Physics3DComponent.create(rigidBody);
component = new jsb.Physics3DComponent(rigidBody);
var sprite = new jsb.Sprite3D("Sprite3DTest/boss.c3b");
sprite.addComponent(component);
sprite.setRotation3D(cc.math.vec3(-90, 0, 0));

View File

@ -1190,7 +1190,7 @@ var Sprite3DLightMapTest = Sprite3DTestDemo.extend({
var light = jsb.PointLight.create(cc.math.vec3(35, 75, -20.5), cc.color(255, 255, 255), 150);
this.addChild(light);
//set the ambient light
var ambient = jsb.AmbientLight.create(cc.color(55, 55, 55));
var ambient = new jsb.AmbientLight(cc.color(55, 55, 55));
this.addChild(ambient);
//create a listener