Esempio n. 1
0
void
OculusVRCamera::targetAddedHandler(AbsCmpPtr component, NodePtr target)
{
	if (targets().size() > 1)
		throw std::logic_error("The OculusVRCamera component cannot have more than 1 target.");

	_addedSlot = target->added()->connect(std::bind(
		&OculusVRCamera::addedHandler,
		shared_from_this(),
		std::placeholders::_1,
		std::placeholders::_2,
		std::placeholders::_3
	));

	_removedSlot = target->removed()->connect(std::bind(
		&OculusVRCamera::removedHandler,
		shared_from_this(),
		std::placeholders::_1,
		std::placeholders::_2,
		std::placeholders::_3
	));

	_targetComponentAddedHandler = target->componentAdded()->connect(std::bind(
		&OculusVRCamera::targetComponentAddedHandler,
		shared_from_this(),
		std::placeholders::_1,
		std::placeholders::_2,
		std::placeholders::_3
	));

	_targetComponentRemovedHandler = target->componentRemoved()->connect(std::bind(
		&OculusVRCamera::targetComponentRemovedHandler,
		shared_from_this(),
		std::placeholders::_1,
		std::placeholders::_2,
		std::placeholders::_3
	));

	_targetTransform = target->hasComponent<Transform>() 
		? target->component<Transform>()
		: nullptr;

	addedHandler(target->root(), target, target->parent());

}
void
AbstractNextFrameComponent::targetAddedHandler(AbstractComponent::Ptr cmp, NodePtr target)
{
	_componentAddedSlot = target->componentAdded()->connect(std::bind(
		&AbstractNextFrameComponent::componentAddedHandler,
		shared_from_this(),
		std::placeholders::_1,
		std::placeholders::_2,
		std::placeholders::_3
	));

	_componentRemovedSlot = target->componentRemoved()->connect(std::bind(
		&AbstractNextFrameComponent::componentRemovedHandler,
		shared_from_this(),
		std::placeholders::_1,
		std::placeholders::_2,
		std::placeholders::_3
	));
}