本文整理汇总了C++中Portal::getTargetPortal方法的典型用法代码示例。如果您正苦于以下问题:C++ Portal::getTargetPortal方法的具体用法?C++ Portal::getTargetPortal怎么用?C++ Portal::getTargetPortal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portal
的用法示例。
在下文中一共展示了Portal::getTargetPortal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleCamera
void handleCamera(Camera * camera)
{
vec3 oldCameraPos = camera->getPosition();
vec3 move(glfwGetKey('D')-glfwGetKey('A'),0,glfwGetKey('S')-glfwGetKey('W'));
move *= 0.1f;
camera->move(move);
vec3 newCameraPos = camera->getPosition();
vec2 lookVec( glfwGetKey(GLFW_KEY_LEFT)-glfwGetKey(GLFW_KEY_RIGHT),
glfwGetKey(GLFW_KEY_UP)-glfwGetKey(GLFW_KEY_DOWN));
camera->rotateY(lookVec.x * 2.0);
// Handle portaling :)
Module * currentModule = camera->getOwnerModule();
std::vector<Portal*> portals = currentModule->getPortals();
for(u32 i=0; i<portals.size(); ++i)
{
Portal * portal = portals[i];
if( intersectLinePortal(oldCameraPos, newCameraPos, *portal) )
{
camera->getOwnerModule()->removeGameObject(camera);
portal->getTargetPortal()->getOwnerModule()->addGameObject(camera);
camera->setTransform(portal->getInvViewMatrix(camera));
}
}
}
示例2: _checkNodeAgainstPortals
void DefaultZone::_checkNodeAgainstPortals(PCZSceneNode * pczsn, Portal * ignorePortal)
{
if (pczsn == mEnclosureNode ||
pczsn->allowedToVisit() == false)
{
// don't do any checking of enclosure node versus portals
return;
}
PCZone * connectedZone;
for ( PortalList::iterator it = mPortals.begin(); it != mPortals.end(); ++it )
{
Portal * p = *it;
//Check if the portal intersects the node
if (p != ignorePortal &&
p->intersects(pczsn) != Portal::NO_INTERSECT)
{
// node is touching this portal
connectedZone = p->getTargetZone();
// add zone to the nodes visiting zone list unless it is the home zone of the node
if (connectedZone != pczsn->getHomeZone() &&
!pczsn->isVisitingZone(connectedZone))
{
pczsn->addZoneToVisitingZonesMap(connectedZone);
// tell the connected zone that the node is visiting it
connectedZone->_addNode(pczsn);
//recurse into the connected zone
connectedZone->_checkNodeAgainstPortals(pczsn, p->getTargetPortal());
}
}
}
}
示例3: destroyPortal
// delete a portal instance by pointer
void PCZSceneManager::destroyPortal(const String & portalName)
{
// find the portal from the master portal list
Portal * p;
Portal * thePortal = 0;
PortalList::iterator it = mPortals.begin();
while (it != mPortals.end())
{
p = *it;
if (p->getName() == portalName)
{
thePortal = p;
// erase entry in the master list
mPortals.erase(it);
break;
}
it++;
}
if (thePortal)
{
// remove the portal from it's target portal
Portal * targetPortal = thePortal->getTargetPortal();
if (targetPortal)
{
targetPortal->setTargetPortal(0); // the targetPortal will still have targetZone value, but targetPortal will be invalid
}
// remove the Portal from it's home zone
PCZone * homeZone = thePortal->getCurrentHomeZone();
if (homeZone)
{
// inform zone of portal change
homeZone->setPortalsUpdated(true);
homeZone->_removePortal(thePortal);
}
// delete the portal instance
OGRE_DELETE thePortal;
}
}
示例4: _checkLightAgainstPortals
/** (recursive) check the given light against all portals in the zone
* NOTE: This is the default implementation, which doesn't take advantage
* of any zone-specific optimizations for checking portal visibility
*/
void DefaultZone::_checkLightAgainstPortals(PCZLight *light,
unsigned long frameCount,
PCZFrustum *portalFrustum,
Portal * ignorePortal)
{
for ( PortalList::iterator it = mPortals.begin(); it != mPortals.end(); ++it )
{
Portal * p = *it;
if (p != ignorePortal)
{
// calculate the direction vector from light to portal
Vector3 lightToPortal = p->getDerivedCP() - light->getDerivedPosition();
if (portalFrustum->isVisible(p))
{
// portal is facing the light, but some light types need to
// check illumination radius too.
PCZone * targetZone = p->getTargetZone();
switch(light->getType())
{
case Light::LT_POINT:
// point lights - just check if within illumination range
if (lightToPortal.length() <= light->getAttenuationRange())
{
// if portal is quad portal it must be pointing towards the light
if ((p->getType() == Portal::PORTAL_TYPE_QUAD && lightToPortal.dotProduct(p->getDerivedDirection()) < 0.0) ||
(p->getType() != Portal::PORTAL_TYPE_QUAD))
{
if (!light->affectsZone(targetZone))
{
light->addZoneToAffectedZonesList(targetZone);
if (targetZone->getLastVisibleFrame() == frameCount)
{
light->setAffectsVisibleZone(true);
}
// set culling frustum from the portal
portalFrustum->addPortalCullingPlanes(p);
// recurse into the target zone of the portal
p->getTargetZone()->_checkLightAgainstPortals(light,
frameCount,
portalFrustum,
p->getTargetPortal());
// remove the planes added by this portal
portalFrustum->removePortalCullingPlanes(p);
}
}
}
break;
case Light::LT_DIRECTIONAL:
// directionals have infinite range, so just make sure
// the direction is facing the portal
if (lightToPortal.dotProduct(light->getDerivedDirection()) >= 0.0)
{
// if portal is quad portal it must be pointing towards the light
if ((p->getType() == Portal::PORTAL_TYPE_QUAD && lightToPortal.dotProduct(p->getDerivedDirection()) < 0.0) ||
(p->getType() != Portal::PORTAL_TYPE_QUAD))
{
if (!light->affectsZone(targetZone))
{
light->addZoneToAffectedZonesList(targetZone);
if (targetZone->getLastVisibleFrame() == frameCount)
{
light->setAffectsVisibleZone(true);
}
// set culling frustum from the portal
portalFrustum->addPortalCullingPlanes(p);
// recurse into the target zone of the portal
p->getTargetZone()->_checkLightAgainstPortals(light,
frameCount,
portalFrustum,
p->getTargetPortal());
// remove the planes added by this portal
portalFrustum->removePortalCullingPlanes(p);
}
}
}
break;
case Light::LT_SPOTLIGHT:
// spotlights - just check if within illumination range
// Technically, we should check if the portal is within
// the cone of illumination, but for now, we'll leave that
// as a future optimisation.
if (lightToPortal.length() <= light->getAttenuationRange())
{
// if portal is quad portal it must be pointing towards the light
if ((p->getType() == Portal::PORTAL_TYPE_QUAD && lightToPortal.dotProduct(p->getDerivedDirection()) < 0.0) ||
(p->getType() != Portal::PORTAL_TYPE_QUAD))
{
if (!light->affectsZone(targetZone))
{
light->addZoneToAffectedZonesList(targetZone);
if (targetZone->getLastVisibleFrame() == frameCount)
{
light->setAffectsVisibleZone(true);
}
// set culling frustum from the portal
portalFrustum->addPortalCullingPlanes(p);
//.........这里部分代码省略.........