本文整理汇总了C++中Constraint::SetHighLimit方法的典型用法代码示例。如果您正苦于以下问题:C++ Constraint::SetHighLimit方法的具体用法?C++ Constraint::SetHighLimit怎么用?C++ Constraint::SetHighLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Constraint
的用法示例。
在下文中一共展示了Constraint::SetHighLimit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateRagdollConstraint
void CreateRagdoll::CreateRagdollConstraint(const String& boneName, const String& parentName, ConstraintType type,
const Vector3& axis, const Vector3& parentAxis, const Vector2& highLimit, const Vector2& lowLimit,
bool disableCollision)
{
Node* boneNode = node_->GetChild(boneName, true);
Node* parentNode = node_->GetChild(parentName, true);
if (!boneNode)
{
URHO3D_LOGWARNING("Could not find bone " + boneName + " for creating ragdoll constraint");
return;
}
if (!parentNode)
{
URHO3D_LOGWARNING("Could not find bone " + parentName + " for creating ragdoll constraint");
return;
}
Constraint* constraint = boneNode->CreateComponent<Constraint>();
constraint->SetConstraintType(type);
// Most of the constraints in the ragdoll will work better when the connected bodies don't collide against each other
constraint->SetDisableCollision(disableCollision);
// The connected body must be specified before setting the world position
constraint->SetOtherBody(parentNode->GetComponent<RigidBody>());
// Position the constraint at the child bone we are connecting
constraint->SetWorldPosition(boneNode->GetWorldPosition());
// Configure axes and limits
constraint->SetAxis(axis);
constraint->SetOtherAxis(parentAxis);
constraint->SetHighLimit(highLimit);
constraint->SetLowLimit(lowLimit);
}
示例2: InitWheel
void Vehicle::InitWheel(const String& name, const Vector3& offset, WeakPtr<Node>& wheelNode, unsigned& wheelNodeID)
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
// Note: do not parent the wheel to the hull scene node. Instead create it on the root level and let the physics
// constraint keep it together
wheelNode = GetScene()->CreateChild(name);
wheelNode->SetPosition(node_->LocalToWorld(offset));
wheelNode->SetRotation(node_->GetRotation() * (offset.x_ >= 0.0 ? Quaternion(0.0f, 0.0f, -90.0f) :
Quaternion(0.0f, 0.0f, 90.0f)));
wheelNode->SetScale(Vector3(0.8f, 0.5f, 0.8f));
// Remember the ID for serialization
wheelNodeID = wheelNode->GetID();
StaticModel* wheelObject = wheelNode->CreateComponent<StaticModel>();
RigidBody* wheelBody = wheelNode->CreateComponent<RigidBody>();
CollisionShape* wheelShape = wheelNode->CreateComponent<CollisionShape>();
Constraint* wheelConstraint = wheelNode->CreateComponent<Constraint>();
wheelObject->SetModel(cache->GetResource<Model>("Models/Cylinder.mdl"));
wheelObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
wheelObject->SetCastShadows(true);
wheelShape->SetSphere(1.0f);
wheelBody->SetFriction(1.0f);
wheelBody->SetMass(1.0f);
wheelBody->SetLinearDamping(0.2f); // Some air resistance
wheelBody->SetAngularDamping(0.75f); // Could also use rolling friction
wheelBody->SetCollisionLayer(1);
wheelConstraint->SetConstraintType(CONSTRAINT_HINGE);
wheelConstraint->SetOtherBody(GetComponent<RigidBody>()); // Connect to the hull body
wheelConstraint->SetWorldPosition(wheelNode->GetPosition()); // Set constraint's both ends at wheel's location
wheelConstraint->SetAxis(Vector3::UP); // Wheel rotates around its local Y-axis
wheelConstraint->SetOtherAxis(offset.x_ >= 0.0 ? Vector3::RIGHT : Vector3::LEFT); // Wheel's hull axis points either left or right
wheelConstraint->SetLowLimit(Vector2(-180.0f, 0.0f)); // Let the wheel rotate freely around the axis
wheelConstraint->SetHighLimit(Vector2(180.0f, 0.0f));
wheelConstraint->SetDisableCollision(true); // Let the wheel intersect the vehicle hull
}