From 9c550e0a113dfd69471a2a599e9b419f3f1ba022 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 17 Jun 2015 13:58:05 +0800 Subject: [PATCH] Update the Physics3DTest for js and Lua by synchronizing the API. --- .../src/Physics3DTest/Physics3DTest.js | 26 +++++++++---------- .../src/Physics3DTest/Physics3DTest.lua | 26 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/js-tests/src/Physics3DTest/Physics3DTest.js b/tests/js-tests/src/Physics3DTest/Physics3DTest.js index 41184ae602..9e4544513c 100644 --- a/tests/js-tests/src/Physics3DTest/Physics3DTest.js +++ b/tests/js-tests/src/Physics3DTest/Physics3DTest.js @@ -138,7 +138,7 @@ var Physics3DTestDemo = cc.Layer.extend({ this.addChild(sprite); sprite.setPosition3D(this._camera.getPosition3D()); sprite.setScale(0.5); - sprite.syncToNode(); + sprite.syncNodeToPhysics(); sprite.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE); sprite.setCameraMask(cc.CameraFlag.USER1); }, @@ -250,7 +250,7 @@ var BasicPhysics3DDemo = Physics3DTestDemo.extend({ floor.setScaleZ(60); this.addChild(floor); floor.setCameraMask(cc.CameraFlag.USER1); - floor.syncToNode(); + floor.syncNodeToPhysics(); //static object sync is not needed floor.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE); @@ -270,7 +270,7 @@ var BasicPhysics3DDemo = Physics3DTestDemo.extend({ var sprite = cc.PhysicsSprite3D.create("Sprite3DTest/box.c3t", rbDes); sprite.setTexture("Images/CyanSquare.png"); sprite.setPosition3D(cc.math.vec3(x, y, z)); - sprite.syncToNode(); + sprite.syncNodeToPhysics(); sprite.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE); sprite.setCameraMask(cc.CameraFlag.USER1); sprite.setScale(0.8); @@ -305,7 +305,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ sprite.setCameraMask(cc.CameraFlag.USER1); sprite.setScale(0.4); sprite.setPosition3D(cc.math.vec3(-20, 5, 0)); - component.syncToNode(); + component.syncNodeToPhysics(); component.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE); physicsScene.setPhysics3DDebugCamera(this._camera); @@ -327,7 +327,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ sprite.addComponent(component); sprite.setCameraMask(cc.CameraFlag.USER1); this.addChild(sprite); - component.syncToNode(); + component.syncNodeToPhysics(); rigidBody.setAngularVelocity(cc.math.vec3(0, 3, 0)); constraint = cc.Physics3DHingeConstraint.create(rigidBody, cc.math.vec3(4, 4, 0.5), cc.math.vec3(0, 1, 0)); physicsScene.getPhysics3DWorld().addPhysics3DConstraint(constraint); @@ -345,7 +345,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ sprite.addComponent(component); sprite.setCameraMask(cc.CameraFlag.USER1); this.addChild(sprite); - component.syncToNode(); + component.syncNodeToPhysics(); rigidBody.setLinearVelocity(cc.math.vec3(0, 3, 0)); rbDes.mass = 0; @@ -359,7 +359,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ sprite.addComponent(component); sprite.setCameraMask(cc.CameraFlag.USER1); this.addChild(sprite); - component.syncToNode(); + component.syncNodeToPhysics(); var frameInA = [-4.37114e-08, 1, 0, 0, -1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0, -5, 0, 1]; var frameInB = [-4.37114e-08, 1, 0, 0, -1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0, 5, 0, 1]; @@ -380,7 +380,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ sprite.addComponent(component); sprite.setCameraMask(cc.CameraFlag.USER1); this.addChild(sprite); - component.syncToNode(); + component.syncNodeToPhysics(); frameInA = [-4.37114e-08, 1, 0, 0, -1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0, -10, 0, 1]; constraint = cc.Physics3DConeTwistConstraint.create(rigidBody, frameInA); @@ -399,7 +399,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ sprite.addComponent(component); sprite.setCameraMask(cc.CameraFlag.USER1); this.addChild(sprite); - component.syncToNode(); + component.syncNodeToPhysics(); frameInA = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; constraint = cc.Physics3D6DofConstraint.create(rigidBody, frameInA, false); @@ -428,7 +428,7 @@ var Physics3DKinematicDemo = Physics3DTestDemo.extend({ floor.setPosition3D(cc.math.vec3(0, -1, 0)); this.addChild(floor); floor.setCameraMask(cc.CameraFlag.USER1); - floor.syncToNode(); + floor.syncNodeToPhysics(); //static object sync is not needed floor.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE); @@ -472,7 +472,7 @@ var Physics3DKinematicDemo = Physics3DTestDemo.extend({ var sprite = cc.PhysicsSprite3D.create("Sprite3DTest/sphere.c3b", rbDes); sprite.setTexture("Sprite3DTest/plane.png"); sprite.setPosition3D(cc.math.vec3(x, y, z)); - sprite.syncToNode(); + sprite.syncNodeToPhysics(); sprite.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE); sprite.setCameraMask(cc.CameraFlag.USER1); sprite.setScale(1/sprite.getContentSize().width); @@ -571,7 +571,7 @@ var Physics3DTerrainDemo = Physics3DTestDemo.extend({ var rigidBody = cc.Physics3DRigidBody.create(rbDes); var component = cc.Physics3DComponent.create(rigidBody); terrain.addComponent(component); - component.syncToNode(); + component.syncNodeToPhysics(); component.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE); this.addChild(terrain); @@ -593,7 +593,7 @@ var Physics3DTerrainDemo = Physics3DTestDemo.extend({ var sprite = cc.PhysicsSprite3D.create("Sprite3DTest/sphere.c3b", rbDes); sprite.setTexture("Sprite3DTest/plane.png"); sprite.setPosition3D(cc.math.vec3(x, y, z)); - sprite.syncToNode(); + sprite.syncNodeToPhysics(); sprite.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE); sprite.setCameraMask(cc.CameraFlag.USER1); sprite.setScale(1/sprite.getContentSize().width); diff --git a/tests/lua-tests/src/Physics3DTest/Physics3DTest.lua b/tests/lua-tests/src/Physics3DTest/Physics3DTest.lua index 0e47383996..1594bbed8e 100644 --- a/tests/lua-tests/src/Physics3DTest/Physics3DTest.lua +++ b/tests/lua-tests/src/Physics3DTest/Physics3DTest.lua @@ -63,7 +63,7 @@ function Physics3DTestDemo:shootBox(des) self:addChild(sprite) sprite:setPosition3D(self._camera:getPosition3D()) sprite:setScale(0.5) - sprite:syncToNode() + sprite:syncNodeToPhysics() --optimize, only sync node to physics sprite:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE) --sync node to physics @@ -184,7 +184,7 @@ function BasicPhysics3DDemo:extend() floor:setScaleZ(60) self:addChild(floor) floor:setCameraMask(cc.CameraFlag.USER1) - floor:syncToNode() + floor:syncNodeToPhysics() floor:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE) rbDes.mass = 1.0 @@ -204,7 +204,7 @@ function BasicPhysics3DDemo:extend() local sprite = cc.PhysicsSprite3D:create("Sprite3DTest/box.c3t", rbDes) sprite:setTexture("Images/CyanSquare.png") sprite:setPosition3D(cc.vec3(x, y, z)) - sprite:syncToNode() + sprite:syncNodeToPhysics() sprite:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE) sprite:setCameraMask(cc.CameraFlag.USER1) sprite:setScale(0.8) @@ -332,7 +332,7 @@ function Physics3DConstraintDemo:extend() sprite:setScale(0.4) sprite:setPosition3D(cc.vec3(-20.0, 5.0, 0.0)) --sync node position to physics - component:syncToNode() + component:syncNodeToPhysics() --physics controlled, we will not set position for it, so we can skip sync node position to physics component:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE) @@ -356,7 +356,7 @@ function Physics3DConstraintDemo:extend() sprite:addComponent(component) sprite:setCameraMask(cc.CameraFlag.USER1) self:addChild(sprite) - component:syncToNode() + component:syncNodeToPhysics() rigidBody:setAngularVelocity(cc.vec3(0,3,0)) constraint = cc.Physics3DHingeConstraint:create(rigidBody, cc.vec3(4.0, 4.0, 0.5), cc.vec3(0.0, 1.0, 0.0)) physicsWorld:addPhysics3DConstraint(constraint) @@ -374,7 +374,7 @@ function Physics3DConstraintDemo:extend() sprite:addComponent(component) sprite:setCameraMask(cc.CameraFlag.USER1) self:addChild(sprite) - component:syncToNode() + component:syncNodeToPhysics() rigidBody:setLinearVelocity(cc.vec3(0,3,0)) rbDes.mass = 0.0 @@ -388,7 +388,7 @@ function Physics3DConstraintDemo:extend() sprite:addComponent(component) sprite:setCameraMask(cc.CameraFlag.USER1) self:addChild(sprite) - component:syncToNode() + component:syncNodeToPhysics() local frameInA = cc.mat4.createRotationZ(cc.mat4.createIdentity(), math.pi / 2) local frameInB = frameInA @@ -411,7 +411,7 @@ function Physics3DConstraintDemo:extend() sprite:addComponent(component) sprite:setCameraMask(cc.CameraFlag.USER1) self:addChild(sprite) - component:syncToNode() + component:syncNodeToPhysics() frameInA = cc.mat4.createRotationZ(frameInA, math.pi / 2) frameInA[13] = 0.0 @@ -433,7 +433,7 @@ function Physics3DConstraintDemo:extend() sprite:addComponent(component) sprite:setCameraMask(cc.CameraFlag.USER1) self:addChild(sprite) - component:syncToNode() + component:syncNodeToPhysics() frameInA = cc.mat4.setIdentity(frameInA) constraint = cc.Physics3D6DofConstraint:create(rigidBody, frameInA, false) physicsWorld:addPhysics3DConstraint(constraint) @@ -463,7 +463,7 @@ function Physics3DKinematicDemo:extend() floor:setPosition3D(cc.vec3(0.0, -1.0, 0.0)) self:addChild(floor) floor:setCameraMask(cc.CameraFlag.USER1) - floor:syncToNode() + floor:syncNodeToPhysics() --static object sync is not needed floor:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE) @@ -514,7 +514,7 @@ function Physics3DKinematicDemo:extend() sprite:setScale(1.00 / sprite:getContentSize().width) self:addChild(sprite) sprite:setPosition3D(cc.vec3(x, y, z)) - sprite:syncToNode() + sprite:syncNodeToPhysics() sprite:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE) end end @@ -608,7 +608,7 @@ function Physics3DTerrainDemo:extend() local component = cc.Physics3DComponent:create(rigidBody) terrain:addComponent(component) self:addChild(terrain) - component:syncToNode() + component:syncNodeToPhysics() component:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE) --create several spheres @@ -631,7 +631,7 @@ function Physics3DTerrainDemo:extend() sprite:setScale(1.0 / sprite:getContentSize().width) sprite:setPosition3D(cc.vec3(x, y, z)) self:addChild(sprite) - sprite:syncToNode() + sprite:syncNodeToPhysics() sprite:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE) end end