当前位置: 首页>>代码示例>>C++>>正文


C++ PCPlane::getPortal方法代码示例

本文整理汇总了C++中PCPlane::getPortal方法的典型用法代码示例。如果您正苦于以下问题:C++ PCPlane::getPortal方法的具体用法?C++ PCPlane::getPortal怎么用?C++ PCPlane::getPortal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PCPlane的用法示例。


在下文中一共展示了PCPlane::getPortal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: removePortalCullingPlanes

	// remove culling planes created from the given portal
	void PCZFrustum::removePortalCullingPlanes(PortalBase* portal)
	{
        PCPlaneList::iterator pit = mActiveCullingPlanes.begin();
        while ( pit != mActiveCullingPlanes.end() )
        {
            PCPlane * plane = *pit;
			if (plane->getPortal() == portal)
			{
				// put the plane back in the reservoir
				mCullingPlaneReservoir.push_front(plane);
				// erase the entry from the active culling plane list
                pit = mActiveCullingPlanes.erase(pit);
			}
            else
            {
                pit++;
            }
        }

    }
开发者ID:j-rivero,项目名称:ogre-acornacorn,代码行数:21,代码来源:OgrePCZFrustum.cpp

示例2: isFullyVisible

	/* special function that returns true only when portal fully fits inside the frustum. */
	bool PCZFrustum::isFullyVisible(const PortalBase* portal) const
	{
		// if portal isn't enabled, it's not visible
		if (!portal->getEnabled()) return false;

		// if the frustum has no planes, just return true
		if (mActiveCullingPlanes.empty())
		{
			return true;
		}
		// check if this portal is already in the list of active culling planes (avoid
		// infinite recursion case)
		PCPlaneList::const_iterator pit = mActiveCullingPlanes.begin();
		while ( pit != mActiveCullingPlanes.end() )
		{
			PCPlane * plane = *pit;
			if (plane->getPortal() == portal)
			{
				return false;
			}
			pit++;
		}
		// if portal is of type AABB or Sphere, then use simple bound check against planes
		if (portal->getType() == PortalBase::PORTAL_TYPE_AABB)
		{
			AxisAlignedBox aabb;
			aabb.setExtents(portal->getDerivedCorner(0), portal->getDerivedCorner(1));
			return isFullyVisible(aabb);
		}
		else if (portal->getType() == PortalBase::PORTAL_TYPE_SPHERE)
		{
			return isFullyVisible(portal->getDerivedSphere());
		}

		// only do this check if it's a portal. (anti portal doesn't care about facing)
		if (portal->getTypeFlags() == PortalFactory::FACTORY_TYPE_FLAG)
		{
			// check if the portal norm is facing the frustum
			Vector3 frustumToPortal = portal->getDerivedCP() - mOrigin;
			Vector3 portalDirection = portal->getDerivedDirection();
			Real dotProduct = frustumToPortal.dotProduct(portalDirection);
			if ( dotProduct > 0 )
			{
				// portal is faced away from Frustum 
				return false;
			}
		}

		// Check originPlane if told to
		if (mUseOriginPlane)
		{
			// we have to check each corner of the portal
			for (int corner = 0; corner < 4; corner++)
			{
				Plane::Side side = mOriginPlane.getSide(portal->getDerivedCorner(corner));
				if (side == Plane::NEGATIVE_SIDE) return false;
			}
		}

		// For each active culling plane, see if any portal points are on the negative 
		// side. If so, the portal is not fully visible
		pit = mActiveCullingPlanes.begin();
		while ( pit != mActiveCullingPlanes.end() )
		{
			PCPlane * plane = *pit;
			// we have to check each corner of the portal
			for (int corner = 0; corner < 4; corner++)
			{
				Plane::Side side =plane->getSide(portal->getDerivedCorner(corner));
				if (side == Plane::NEGATIVE_SIDE) return false;
			}
			pit++;
		}
		// no plane culled all the portal points and the norm
		// was facing the frustum, so this portal is fully visible
		return true;
	}
开发者ID:j-rivero,项目名称:ogre-acornacorn,代码行数:78,代码来源:OgrePCZFrustum.cpp

示例3: isVisible

    // NOTE: Everything needs to be updated spatially before this function is
    //       called including portal corners, frustum planes, etc.
    bool PCZFrustum::isVisible(Portal * portal)
    {
		// if portal isn't open, it's not visible
		if (!portal->isOpen())
		{
			return false;
		}

		// if the frustum has no planes, just return true
        if (mActiveCullingPlanes.size() == 0)
        {
            return true;
        }
		// check if this portal is already in the list of active culling planes (avoid
		// infinite recursion case)
        PCPlaneList::const_iterator pit = mActiveCullingPlanes.begin();
        while ( pit != mActiveCullingPlanes.end() )
        {
            PCPlane * plane = *pit;
			if (plane->getPortal() == portal)
			{
				return false;
			}
            pit++;
        }
		// if portal is of type AABB or Sphere, then use simple bound check against planes
		if (portal->getType() == Portal::PORTAL_TYPE_AABB)
		{
			AxisAlignedBox aabb;
			aabb.setExtents(portal->getDerivedCorner(0), portal->getDerivedCorner(1));
			return isVisible(aabb);
		}
		else if (portal->getType() == Portal::PORTAL_TYPE_SPHERE)
		{
			return isVisible(portal->getDerivedSphere());
		}

        // check if the portal norm is facing the frustum
		Vector3 frustumToPortal = portal->getDerivedCP() - mOrigin;
		Vector3 portalDirection = portal->getDerivedDirection();
		Real dotProduct = frustumToPortal.dotProduct(portalDirection);
		if ( dotProduct > 0 )
        {
            // portal is faced away from Frustum 
            return false;
        }

        // check against frustum culling planes
        bool visible_flag;

        // Check originPlane if told to
        if (mUseOriginPlane)
        {
            // set the visible flag to false
            visible_flag = false;
            // we have to check each corner of the portal
            for (int corner = 0; corner < 4; corner++)
            {
                Plane::Side side = mOriginPlane.getSide(portal->getDerivedCorner(corner));
                if (side != Plane::NEGATIVE_SIDE)
                {
                    visible_flag = true;
                }
            }
            // if the visible_flag is still false, then the origin plane
            // culled all the portal points
            if (visible_flag == false)
            {
                // ALL corners on negative side therefore out of view
                return false;
            }
        }

        // For each active culling plane, see if all portal points are on the negative 
        // side. If so, the portal is not visible
        pit = mActiveCullingPlanes.begin();
        while ( pit != mActiveCullingPlanes.end() )
        {
            PCPlane * plane = *pit;
            // set the visible flag to false
            visible_flag = false;
            // we have to check each corner of the portal
            for (int corner = 0; corner < 4; corner++)
            {
                Plane::Side side =plane->getSide(portal->getDerivedCorner(corner));
                if (side != Plane::NEGATIVE_SIDE)
                {
                    visible_flag = true;
                }
            }
            // if the visible_flag is still false, then this plane
            // culled all the portal points
            if (visible_flag == false)
            {
                // ALL corners on negative side therefore out of view
                return false;
            }
            pit++;
//.........这里部分代码省略.........
开发者ID:jjiezheng,项目名称:pap_full,代码行数:101,代码来源:OgrePCZFrustum.cpp


注:本文中的PCPlane::getPortal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。