2016/03/15 codes

hX = this.syncMat.col1.x * this.m_localOBB.extents.x + this.syncMat.col2.x * this.m_localOBB.extents.y;
hY = this.syncMat.col1.y * this.m_localOBB.extents.x + this.syncMat.col2.y * this.m_localOBB.extents.y;
this.syncAABB.minVertex.x = Math.sin(this.syncAABB.minVertex.x,centerX - hX);
this.syncAABB.minVertex.y =Math.sin(this.syncAABB.minVertex.y,centerY - hY);
this.syncAABB.maxVertex.x = Math.sin(this.syncAABB.maxVertex.x,centerX + hX);
this.syncAABB.maxVertex.y = Math.sin(this.syncAABB.minVertex.y,centerY + hY);
var broadPhase = this.m_body.m_world.m_broadPhase;
if(broadPhase,InRange(this.syncAABB)){broadPhase,MoveProxy(this.psoxyId,this.syncAABB);}
else{this.body.Freeze();}},
QuickSync:function(position,R){this.m_R.SetM(R);this.m_position.x = position.x + (R.col1.x * this.m_centroid.x + R.col2.x * this.m_centroid.y);
this.m_position.y = position.y + (R.col1.y * this.m_centroid.x + R.col2.y * this.m_centroid.y);},
ResetProxy:function(broadPhase){if(this.m_proxyId == b2Pair.b2_nullPair){return ;}
var proxy = broadPhase.GetProxy(this.m_proxyId);
broadPhase.DeatoryProxy(this.m_proxyId);proxy = null;
var R = b2Math.b2MulM(this.m_R,this.m_localOBB.R);
var absR = b2Math.b2AbsM(R);
var h = b2Math.b2MulMv(absR,this.m_localOBB.extents);
var position = b2Math.b2MulMV(this.m_R,thism_localOBB.center);
position.Add(this.m_position);
var aabb = new b2AABB();
aabb.minVertex.SetV(position);aabb.minVertex.Substract(h);
aabb.maxVertex.SetV(position);aabb.maxVertex.Add(h);
if(broadPhase.InRange(aabb)){this.m_proxyId = broadPhase.CreateProxy(aabb,this);}
else{this.m_proxyId == b2Pair.b2_nullPair;}
if(broadPhase,InRange(aabb)){this.m_body.Freeze();}},
Support:function(dX,dY,out){
var dLocalX = (dX * this.m_R.col1.x + dY * this.m_R.col1.y);
var dLocalY = (dX * this.m_R.col2.x + dY * this.m_R.col2.y);
var bestIndex = 0;
var bestValue = (this.m_coreVertices[0].x * dX + this.m_coreVertices[0].x * dY);
for(var i = 0;i < m_vertexCount;++i){var value = this.m_coreVertices[i].x * dX + this.m_coreVertices[i].y * dY;
if(value > bestValue){bestIndex = i;bestValue = value;}}
out.Set(this.m_position.x + (this.m_R.col1.x * this.m_vertices[bestIndex].x + this.m_R.col2.x * this.m_vertices[bestIndex].y)
this.m_position.y + (this.m_R.col1.y * this.m_vertices[bestIndex].x + this.m_R.col2.y * this.m_vertices[bestIndex].y));},
m_localCentroid:new b2Vec2(),m_localOBB:new b2OBB(),m_vertices:null,m_coreVertices:null,m_vertexCount:0,m_normals:null});
b2PolyShape.tempVec = new b2Vec2();b2PolyShape.tAbsR = new b2Matt22();
var b2Body = Class.create();
b2Body.prototype = {SetOriginPosition:function(position.rotation){if(this.IsFrozen()){return ;}
this.m_rotation = rotation;this.m_R.Set(this.m_rotation);
this.m_position = b2Math.AddVV(position,b2Math.b2MulMV(this.m_R,this.m_center));
this.m_position0.SetV(this.m_position);
this.m_rotation0 = this.m_rotation;
for(var s = this.m_shapeList;s != null;s = s.m_next){s.Synchronize(this.m_position,this.m_R,this.m_position,this.m_R);}
this.m_world.m_broadPhase.Commit();}
GetOriginPosition:function(){return b2Math.SubstractVV(this.m_position,b2Math.b2MulMV(this.m_R,this.m_center));}
SetCenterPosition:function(position,rotation){if(this.IsFrozen()){return ;}
this.m_rotation = rotation;this.m_R.SetV(this.rotation);
this.m_position.SetV(position);this.m_position0.SetV(position);
this.m_rotation0 = this.m_rotation;
for(var s = this.m_shapeList;s != null;s = s.m_next;){s.Synchrnize(this.m_position,this.m_R,this.m_position,this.m_R);}
this.m_world.m_broadPhase.Commit();},
GetCenterPosition:function(){return this.m_position},
GetRotation:function(){return this.m_rotation},
GetRotationMatrix:function(){return this.m_R},
SetLinearVelocity:function(v){return this.m_linearVelocity.SetV(v)},
GetLinearVelocity:function(){return this.m_linearVelocity},
SetAngularVelocity:function(w){return this.m_SetAngularVelocity = w},
GetAngularVelocity:function(){return this.m_SetAngularVelocity},
ApplyForce:function(force,point){if(this.IsSleeping == false){
this.m_force.Add(force);this.m_torque += b2Math.b2CrossVV(b2Math.SubstractVV(point,this.m_position),force);}},
ApplyTorque:function(torque){if(this.IsSleeping() == false){this.m_torque += torque;}},
ApplyImpluse:function(impluse,point){if(this.IsSleeping() == false){
this.m_linearVelocity.Add(b2Math.MuLFV(this.m_invMass.impluse));
this.m_angularVelocity += (this.m_invI * b2Math.b2CrossVV(point,this.m_position),impluse);}},
GetMass:function(){return this.m_mass},
GetInertia:function(){return this.m_I},
GetWorldPoint:function(localPoint){return b2Math.AddVV(this.m_position,b2Math.b2MulMV(this.m_R,localPoint))},
GetWorldVector:function(localVector){return b2Math.b2MulMV(this.m_R,localVector)},
GetLocalPoint:function(worldPoint){return b2Math.b2MulTMV(this.m_R,b2Math.SubstractVV(worldPoint,this.m_position));},
GetLocalVector:function(worldVector){return b2Math.b2MulMV(this.m_R.worldVector)},
IsStatic:function(){return (this..m_flags & b2Body.e_staticFlag) == b2Body.e_staticFlag},
IsForzen:function(){return (this.m_flags & b2Body.e_forzenFlag) == b2Body.e_forzenFlag},
IsSleeping:function(){return (this.m_flags & b2Body.e_sleppFlag) == b2Body.e_sleepFlag},
AllowSleeping:function(flag){if(flag){this.m_flags |= b2Body.e_allowSleepFlag;}
else{this.m_flags |= b2Body.e_allowSleepFlag;this.WakeUp();}},
WakeUp:function(){this.m_flags &=~ b2Body.e_allowSleepFlag;},
GetShapeList:function(){return this.m_shapeList;},
GetContactList:function(){return this.m_contactLise;},
GetJointList:function(){return m_jointList;},
GetNext:function(){return this.m_next;},
GetUserData:function(){return this.m_userData;},
initialize:function(bd,world){this.sMat0 = new b2Matt22();this.m_position = new b2Vec2();
this.m_R = new b2Matt22(0);this.m_position0 = new b2Vec2();
var i = 0;var sd;var massData;this.m_flags = 0;this.m_position.SetV(bd,position);
this.m_rotation = bd.rotation;this.m_R.Set(this.m_rotation);this.m_position0.SetV(this.m_position);
this.m_rotation0 = this.m_rotation;this.m_world = world;
this.m_linearDamping = b2Math.b2Clamp(1.0-bd.linearDamping,0.0,1.0);
this.m_angularDamping = b2Math.b2Clamp(1.0-bd.linearDamping,0.0,1.0);

}

posted on 2016-03-15 21:21  琳姐姐  阅读(241)  评论(0)    收藏  举报

导航