本文整理汇总了C++中node::Ptr::addComponent方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::addComponent方法的具体用法?C++ Ptr::addComponent怎么用?C++ Ptr::addComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node::Ptr
的用法示例。
在下文中一共展示了Ptr::addComponent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collectAnimatedNodes
void
POPGeometryWriterPreprocessor::process(Node::Ptr& node, AssetLibrary::Ptr assetLibrary)
{
// TODO
// introduce heuristics based on scene layout
// * find object instances within scene hierarchy
// to dispatch lod scheduling components at correspondings object roots, used as
// scene object descriptors specifying type of technique to apply
// by default whole scene is streamed as a progressive ordered mesh
if (!node->hasComponent<POPGeometryLodScheduler>())
node->addComponent(POPGeometryLodScheduler::create());
auto animatedNodes = collectAnimatedNodes(node);
markPOPGeometries(node, animatedNodes);
}
示例2: logic_error
void
bullet::Collider::initializeFromNode(Node::Ptr node)
{
if (_graphicsTransform != nullptr && _physicsWorld != nullptr)
return;
_physicsTransform->identity(); // matrix automatically updated by physicsWorldTransformChangedHandler
// get existing transform component or create one if necessary
if (!node->hasComponent<Transform>())
node->addComponent(Transform::create());
_graphicsTransform = node->component<Transform>();
if (fabsf(_graphicsTransform->modelToWorldMatrix(true)->determinant()) < 1e-4f)
throw std::logic_error("The node's model-to-world matrix cannot be inverted.");
// identify physics world
auto withPhysicsWorld = NodeSet::create(node)
->ancestors(true)
->where([](Node::Ptr n) {
return n->hasComponent<bullet::PhysicsWorld>();
});
if (withPhysicsWorld->nodes().size() > 1)
throw std::logic_error("Scene cannot contain more than one PhysicsWorld component.");
_physicsWorld = withPhysicsWorld->nodes().empty()
? nullptr
: withPhysicsWorld->nodes().front()->component<bullet::PhysicsWorld>();
if (_physicsWorld)
_physicsWorld->addChild(std::static_pointer_cast<Collider>(shared_from_this()));
synchronizePhysicsWithGraphics();
}