本文整理汇总了C++中ToB2Vec2函数的典型用法代码示例。如果您正苦于以下问题:C++ ToB2Vec2函数的具体用法?C++ ToB2Vec2怎么用?C++ ToB2Vec2使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ToB2Vec2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReleaseFixture
void CollisionEdge2D::RecreateFixture()
{
ReleaseFixture();
Vector2 worldScale(cachedWorldScale_.x_, cachedWorldScale_.y_);
edgeShape_.Set(ToB2Vec2(vertex1_ * worldScale), ToB2Vec2(vertex2_ * worldScale));
CreateFixture();
}
示例2: ToB2Vec2
b2JointDef* ConstraintDistance2D::GetJointDef()
{
if (!ownerBody_ || !otherBody_)
return 0;
b2Body* bodyA = ownerBody_->GetBody();
b2Body* bodyB = otherBody_->GetBody();
if (!bodyA || !bodyB)
return 0;
jointDef_.Initialize(bodyA, bodyB, ToB2Vec2(ownerBodyAnchor_), ToB2Vec2(otherBodyAnchor_));
return &jointDef_;
}
示例3: ToB2Vec2
b2JointDef* ConstraintWheel2D::GetJointDef()
{
if (!ownerBody_ || !otherBody_)
return nullptr;
b2Body* bodyA = ownerBody_->GetBody();
b2Body* bodyB = otherBody_->GetBody();
if (!bodyA || !bodyB)
return nullptr;
jointDef_.Initialize(bodyA, bodyB, ToB2Vec2(anchor_), ToB2Vec2(axis_));
return &jointDef_;
}
示例4: ToB2Vec2
void RigidBody2D::CreateBody()
{
if (body_)
return;
if (!physicsWorld_ || !physicsWorld_->GetWorld())
return;
bodyDef_.position = ToB2Vec2(node_->GetWorldPosition());;
bodyDef_.angle = node_->GetWorldRotation().RollAngle() * M_DEGTORAD;
body_ = physicsWorld_->GetWorld()->CreateBody(&bodyDef_);
body_->SetUserData(this);
for (unsigned i = 0; i < collisionShapes_.Size(); ++i)
{
if (collisionShapes_[i])
collisionShapes_[i]->CreateFixture();
}
if (!useFixtureMass_)
body_->SetMassData(&massData_);
for (unsigned i = 0; i < constraints_.Size(); ++i)
{
if (constraints_[i])
constraints_[i]->CreateJoint();
}
}
示例5: InitializeJointDef
b2JointDef* ConstraintRope2D::CreateJointDef()
{
if (!ownerBody_ || !otherBody_)
return 0;
b2Body* bodyA = ownerBody_->GetBody();
b2Body* bodyB = otherBody_->GetBody();
if (!bodyA || !bodyB)
return 0;
b2RopeJointDef* jointDef = new b2RopeJointDef;
InitializeJointDef(jointDef);
jointDef->localAnchorA = ToB2Vec2(ownerBodyAnchor_);
jointDef->localAnchorB = ToB2Vec2(otherBodyAnchor_);
jointDef->maxLength = maxLength_;
return jointDef;
}
示例6: ReleaseFixture
void CollisionCircle2D::RecreateFixture()
{
ReleaseFixture();
// Only use scale in x axis for circle
float worldScale = cachedWorldScale_.x_;
circleShape_.m_radius = radius_ * worldScale;
circleShape_.m_p = ToB2Vec2(center_ * worldScale);
CreateFixture();
}
示例7: RecreateJoint
void ConstraintMotor2D::SetLinearOffset(const Vector2& linearOffset)
{
if (linearOffset == linearOffset_)
return;
linearOffset_ = linearOffset;
if (joint_)
static_cast<b2MotorJoint*>(joint_)->SetLinearOffset(ToB2Vec2(linearOffset));
else
RecreateJoint();
MarkNetworkUpdate();
}
示例8: RecreateJoint
void ConstraintMouse2D::SetTarget(const Vector2& target)
{
if (target == target_)
return;
target_ = target;
if (joint_)
static_cast<b2MouseJoint*>(joint_)->SetTarget(ToB2Vec2(target));
else
RecreateJoint();
MarkNetworkUpdate();
}
示例9: ToB2Vec2
b2JointDef* ConstraintMotor2D::GetJointDef()
{
if (!ownerBody_ || !otherBody_)
return nullptr;
b2Body* bodyA = ownerBody_->GetBody();
b2Body* bodyB = otherBody_->GetBody();
if (!bodyA || !bodyB)
return nullptr;
jointDef_.Initialize(bodyA, bodyB);
jointDef_.linearOffset = ToB2Vec2(linearOffset_);
return &jointDef_;
}
示例10: ReleaseFixture
void CollisionBox2D::RecreateFixture()
{
ReleaseFixture();
float worlsScaleX = cachedWorldScale_.x_;
float worldScaleY = cachedWorldScale_.y_;
float halfWidth = size_.x_ * 0.5f * worlsScaleX;
float halfHeight = size_.y_ * 0.5f * worldScaleY;
Vector2 scaledCenter = center_ * Vector2(worlsScaleX, worldScaleY);
if (scaledCenter == Vector2::ZERO && angle_ == 0.0f)
boxShape_.SetAsBox(halfWidth, halfHeight);
else
boxShape_.SetAsBox(halfWidth, halfHeight, ToB2Vec2(scaledCenter), angle_ * M_DEGTORAD);
CreateFixture();
}
示例11: ToB2Vec2
b2JointDef* ConstraintMouse2D::GetJointDef()
{
if (!ownerBody_ || !otherBody_)
return nullptr;
b2Body* bodyA = otherBody_->GetBody();
b2Body* bodyB = ownerBody_->GetBody();
if (!bodyA || !bodyB)
return nullptr;
jointDef_.bodyA = bodyA;
jointDef_.bodyB = bodyB;
jointDef_.collideConnected = collideConnected_;
jointDef_.target = ToB2Vec2(target_);
return &jointDef_;
}
示例12: ReleaseFixture
void CollisionPolygon2D::RecreateFixture()
{
ReleaseFixture();
if (vertices_.Size() < 3)
return;
PODVector<b2Vec2> b2Vertices;
unsigned count = vertices_.Size();
b2Vertices.Resize(count);
Vector2 worldScale(cachedWorldScale_.x_, cachedWorldScale_.y_);
for (unsigned i = 0; i < count; ++i)
b2Vertices[i] = ToB2Vec2(vertices_[i] * worldScale);
polygonShape_.Set(&b2Vertices[0], count);
CreateFixture();
}
示例13: ReleaseFixture
void CollisionChain2D::RecreateFixture()
{
ReleaseFixture();
PODVector<b2Vec2> b2Vertices;
unsigned count = vertices_.Size();
b2Vertices.Resize(count);
Vector2 worldScale(cachedWorldScale_.x_, cachedWorldScale_.y_);
for (unsigned i = 0; i < count; ++i)
b2Vertices[i] = ToB2Vec2(vertices_[i] * worldScale);
if (loop_)
chainShape_.CreateLoop(&b2Vertices[0], count);
else
chainShape_.CreateChain(&b2Vertices[0], count);
CreateFixture();
}
示例14: ReleaseFixture
void CollisionChain2D::RecreateFixture()
{
ReleaseFixture();
std::vector<b2Vec2> b2Vertices;
size_t count = vertices_.size();
b2Vertices.resize(count);
Vector2 worldScale(cachedWorldScale_.x_, cachedWorldScale_.y_);
for (size_t i = 0; i < count; ++i)
b2Vertices[i] = ToB2Vec2(vertices_[i] * worldScale);
chainShape_.Clear();
if (loop_)
chainShape_.CreateLoop(&b2Vertices[0], count);
else
chainShape_.CreateChain(&b2Vertices[0], count);
CreateFixture();
}
示例15: MarkNetworkUpdate
void ConstraintMouse2D::SetTarget(const Vector2& target)
{
if (target == target_)
return;
target_ = target;
if (joint_ && targetSetted_)
{
b2MouseJoint* mouseJoint = (b2MouseJoint*)joint_;
mouseJoint->SetTarget(ToB2Vec2(target_));
MarkNetworkUpdate();
return;
}
targetSetted_ = true;
RecreateJoint();
MarkNetworkUpdate();
}