本文整理汇总了C++中PCZone::getLastVisibleFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ PCZone::getLastVisibleFrame方法的具体用法?C++ PCZone::getLastVisibleFrame怎么用?C++ PCZone::getLastVisibleFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PCZone
的用法示例。
在下文中一共展示了PCZone::getLastVisibleFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateZones
//-----------------------------------------------------------------------
void PCZLight::updateZones(PCZone * defaultZone, unsigned long frameCount)
{
//update the zones this light affects
PCZone * homeZone;
affectedZonesList.clear();
mAffectsVisibleZone = false;
PCZSceneNode * sn = (PCZSceneNode*)(this->getParentSceneNode());
if (sn)
{
// start with the zone the light is in
homeZone = sn->getHomeZone();
if (homeZone)
{
affectedZonesList.push_back(homeZone);
if (homeZone->getLastVisibleFrame() == frameCount)
{
mAffectsVisibleZone = true;
}
}
else
{
// error - scene node has no homezone!
// just say it affects the default zone and leave it at that.
affectedZonesList.push_back(defaultZone);
if (defaultZone->getLastVisibleFrame() == frameCount)
{
mAffectsVisibleZone = true;
}
return;
}
}
else
{
// ERROR! not connected to a scene node,
// just say it affects the default zone and leave it at that.
affectedZonesList.push_back(defaultZone);
if (defaultZone->getLastVisibleFrame() == frameCount)
{
mAffectsVisibleZone = true;
}
return;
}
// now check visibility of each portal in the home zone. If visible to
// the light then add the target zone of the portal to the list of
// affected zones and recurse into the target zone
static PCZFrustum portalFrustum;
Vector3 v = getDerivedPosition();
portalFrustum.setOrigin(v);
homeZone->_checkLightAgainstPortals(this, frameCount, &portalFrustum, 0);
}
示例2: _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);
//.........这里部分代码省略.........