void BaseRenderComponent::PostInit()
{
	shared_ptr<SceneNode> pSceneNode(GetSceneNode());
	// fire event that a new render component has been created
	shared_ptr<Event_NewRenderComponent> pEvent(CB_NEW Event_NewRenderComponent(m_pOwner->GetId(), pSceneNode));
	IEventManager::Get()->TriggerEvent(pEvent);
}
Esempio n. 2
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
RenderingCanvas::querySceneNodes(Math::Real _x, Math::Real _y, I_SceneNodeVisitor& _visitor)
{
    Ogre::Camera& camera = m_pCurrentCamera->getOgreCamera();
    Ogre::Vector3 position;
    if( camera.getParentSceneNode() )
    {
        position = camera.getParentSceneNode()->_getDerivedPosition();
    }
    else
    {
        position = camera.getDerivedPosition();
    }

    Ogre::RaySceneQuery* pSceneQuery =
        m_pSceneManager->createRayQuery(camera.getCameraToViewportRay(_x, _y));
    pSceneQuery->setSortByDistance(true);

    Ogre::RaySceneQueryResult::const_iterator iter;
    const Ogre::RaySceneQueryResult& queryResult = pSceneQuery->execute();

    _visitor.begin();
    for(iter = queryResult.begin(); iter != queryResult.end(); iter++)
    {
        const Ogre::RaySceneQueryResultEntry& result = *iter;

        // Check to see if this is a scene node.
        if (result.movable != NULL)
        {
            Ogre::SceneNode *pNode = dynamic_cast<Ogre::SceneNode*>(result.movable->getParentSceneNode());
            if (pNode)
            {
                if (!pNode->getUserAny().isEmpty())
                {
                    SceneNode* pRawSceneNode = Ogre::any_cast<SceneNode*>(pNode->getUserAny());

                    I_SceneNodeVisitor::pSceneNode_type pSceneNode(pRawSceneNode->getSelfReference().lock());

                    _visitor.visit(pSceneNode);
                }
            }
        }
    }
    _visitor.end();

    delete pSceneQuery;
}
Esempio n. 3
0
void BaseRenderComponent::VPostInit(void)
{
    shared_ptr<SceneNode> pSceneNode(VGetSceneNode());
	shared_ptr<EventData_New_Render_Component> pEvent(WE_NEW EventData_New_Render_Component(m_pOwner->GetId(), pSceneNode));
	IEventManager::Get()->VTriggerVTriggerEvent(pEvent);
}