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


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

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


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

示例1: addPortalCullingPlanes

	// calculate  culling planes from portal and frustum 
	// origin and add to list of  culling planes
	// NOTE: returns 0 if portal was completely culled by existing planes
	//		 returns > 0 if culling planes are added (# is planes added)
	int PCZFrustum::addPortalCullingPlanes(PortalBase* portal)
	{
		int addedcullingplanes = 0;

		// If portal is of type aabb or sphere, add a plane which is same as frustum
		// origin plane (ie. redundant).  We do this because we need the plane as a flag
		// to prevent infinite recursion 
		if (portal->getType() == PortalBase::PORTAL_TYPE_AABB ||
			portal->getType() == PortalBase::PORTAL_TYPE_SPHERE)
		{
            PCPlane * newPlane = getUnusedCullingPlane();
			newPlane->setFromOgrePlane(mOriginPlane);
            newPlane->setPortal(portal);
            mActiveCullingPlanes.push_front(newPlane);
			addedcullingplanes++;
			return addedcullingplanes;
		}

		// only do this check if it's an anti portal since it's double facing.
		bool flipPlane = false;
		if (portal->getTypeFlags() == AntiPortalFactory::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);

			// it's facing away from the frustum. Flip the planes.
			if (dotProduct > 0) flipPlane = true;
		}

        // For portal Quads: Up to 4 planes can be added by the sides of a portal quad.
        // Each plane is created from 2 corners (world space) of the portal and the
        // frustum origin (world space).
		int i,j;
		Plane::Side pt0_side, pt1_side;
		bool visible;
        PCPlaneList::iterator pit;
        for (i=0;i<4;i++)
        {
            // first check if both corners are outside of one of the existing planes
			j = i+1;
			if (j > 3)
			{
				j = 0;
			}
			visible = true;
            pit = mActiveCullingPlanes.begin();
            while ( pit != mActiveCullingPlanes.end() )
            {
                PCPlane * plane = *pit;
				pt0_side = plane->getSide(portal->getDerivedCorner(i));
				pt1_side = plane->getSide(portal->getDerivedCorner(j));
				if (pt0_side == Plane::NEGATIVE_SIDE &&
					pt1_side == Plane::NEGATIVE_SIDE)
				{
					// the portal edge was actually completely culled by one of  culling planes
					visible = false;
					break;
				}
				pit++;
            }
			if (visible)
			{
				// add the plane created from the two portal corner points and the frustum location
				// to the  culling plane
                PCPlane * newPlane = getUnusedCullingPlane();
				if (mProjType == PT_ORTHOGRAPHIC) // use camera direction if projection is orthographic.
				{
					if (flipPlane)
					{
						newPlane->redefine(portal->getDerivedCorner(j) + mOriginPlane.normal,
							portal->getDerivedCorner(i), portal->getDerivedCorner(j));
					}
					else
					{
						newPlane->redefine(portal->getDerivedCorner(j) + mOriginPlane.normal,
							portal->getDerivedCorner(j), portal->getDerivedCorner(i));
					}
				}
				else
				{
					if (flipPlane)
					{
						newPlane->redefine(mOrigin,
							portal->getDerivedCorner(i),
							portal->getDerivedCorner(j));
					}
					else
					{
						newPlane->redefine(mOrigin,
							portal->getDerivedCorner(j),
							portal->getDerivedCorner(i));
					}
				}
                newPlane->setPortal(portal);
//.........这里部分代码省略.........
开发者ID:j-rivero,项目名称:ogre-acornacorn,代码行数:101,代码来源:OgrePCZFrustum.cpp


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