mirror of https://github.com/axmolengine/axmol.git
add Physics3DPointToPointConstraint support new
This commit is contained in:
parent
1be5981d6a
commit
9c6b5730d0
|
@ -177,8 +177,6 @@ public:
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
Physics3DPointToPointConstraint();
|
Physics3DPointToPointConstraint();
|
||||||
virtual ~Physics3DPointToPointConstraint();
|
virtual ~Physics3DPointToPointConstraint();
|
||||||
|
|
||||||
protected:
|
|
||||||
bool init(Physics3DRigidBody* rbA, const cocos2d::Vec3& pivotPointInA);
|
bool init(Physics3DRigidBody* rbA, const cocos2d::Vec3& pivotPointInA);
|
||||||
bool init(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Vec3& pivotPointInA, const cocos2d::Vec3& pivotPointInB);
|
bool init(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Vec3& pivotPointInA, const cocos2d::Vec3& pivotPointInB);
|
||||||
|
|
||||||
|
|
|
@ -339,4 +339,17 @@ jsb.Physics3DComponent.prototype._ctor = function(physicsObj, translateInPhysics
|
||||||
this.init();
|
this.init();
|
||||||
this.setPhysics3DObject(physicsObj);
|
this.setPhysics3DObject(physicsObj);
|
||||||
this.setTransformInPhysics(translateInPhysics, rotInPhsyics);
|
this.setTransformInPhysics(translateInPhysics, rotInPhsyics);
|
||||||
|
}
|
||||||
|
|
||||||
|
jsb.Physics3DPointToPointConstraint.prototype._ctor = function(first, second, third, fourth){
|
||||||
|
if (arguments.length == 2 ) {
|
||||||
|
this.init(first, second);
|
||||||
|
}
|
||||||
|
else if (arguments.length == 4 ) {
|
||||||
|
this.init(first, second, third, fourth);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Error("error arguments");
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -319,7 +319,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
|
||||||
this._world = physicsScene.getPhysics3DWorld();
|
this._world = physicsScene.getPhysics3DWorld();
|
||||||
|
|
||||||
//create point to point constraint
|
//create point to point constraint
|
||||||
var constraint = jsb.Physics3DPointToPointConstraint.create(rigidBody, cc.math.vec3(2.5, 2.5, 2.5));
|
var constraint = new jsb.Physics3DPointToPointConstraint(rigidBody, cc.math.vec3(2.5, 2.5, 2.5));
|
||||||
this._world.addPhysics3DConstraint(constraint);
|
this._world.addPhysics3DConstraint(constraint);
|
||||||
|
|
||||||
//create hinge constraint
|
//create hinge constraint
|
||||||
|
@ -437,7 +437,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
|
||||||
var mat = cc.math.mat4GetInversed(result.hitObj.getWorldTransform());
|
var mat = cc.math.mat4GetInversed(result.hitObj.getWorldTransform());
|
||||||
var position = cc.math.mat4TransformPoint(mat, result.hitPosition);
|
var position = cc.math.mat4TransformPoint(mat, result.hitPosition);
|
||||||
|
|
||||||
this._constraint = jsb.Physics3DPointToPointConstraint.create(result.hitObj, position);
|
this._constraint = new jsb.Physics3DPointToPointConstraint(result.hitObj, position);
|
||||||
this._world.addPhysics3DConstraint(this._constraint, true);
|
this._world.addPhysics3DConstraint(this._constraint, true);
|
||||||
this._pickingDistance = cc.math.vec3Length(cc.math.vec3Sub(result.hitPosition, nearP));
|
this._pickingDistance = cc.math.vec3Length(cc.math.vec3Sub(result.hitPosition, nearP));
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue