本文整理汇总了C++中WeakPtr::GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ WeakPtr::GetPosition方法的具体用法?C++ WeakPtr::GetPosition怎么用?C++ WeakPtr::GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WeakPtr
的用法示例。
在下文中一共展示了WeakPtr::GetPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}
示例2: HandleUpdate
void Tile::HandleUpdate(StringHash eventType, VariantMap &eventData)
{
double elapsedTime = masterControl_->world.scene->GetElapsedTime();
double offsetY = 0.0;
//Alien Chaos - Disorder = time*1.0525f
//Talpa - Unusual Chair = time*1.444
wave_ = 6.0*pow(masterControl_->Sine(Abs(float(centerDistExp_ - elapsedTime) * 0.666f)), 4.0f);
uint nHexAffectors = tileMaster_->hexAffectors_.Size();
if (nHexAffectors) {
for (uint i = 0; i < nHexAffectors; i++) {
WeakPtr<Node> hexAffector = tileMaster_->hexAffectors_.Keys()[i];
double hexAffectorMass = tileMaster_->hexAffectors_[hexAffector]->GetMass();
if (hexAffector->IsEnabled()) {
double offsetYPart = sqrt(hexAffectorMass) - (0.1* Vector3::Distance(referencePosition_, hexAffector->GetPosition()));
if (offsetYPart > 0.0) {
offsetYPart = pow(offsetYPart, 4);
offsetY += offsetYPart;
}
}
}
offsetY = sqrt(offsetY);
}
offsetY += 0.023f * wave_;
Vector3 lastPos = rootNode_->GetPosition();
Vector3 newPos = Vector3(lastPos.x_, referencePosition_.y_ - offsetY, lastPos.z_);
rootNode_->SetPosition(newPos);
double color = Clamp((0.25f * offsetY) +0.3f, 0.0f, 1.0f);
model_->GetMaterial(0)->SetShaderParameter("MatDiffColor", Color(color, color, color, color + (0.023 * wave_)));
}