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


C++ AABBox::Intersects方法代码示例

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


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

示例1: update

void COpenGLGrassRenderer::update(float fDeltaTimeInSecond, const Vector4D& camPos, const Frustum& viewFrustum, CSGPGrass* pGrass)
{
	m_vCameraPos = camPos;

	m_GrassClusterInstanceArray.clearQuick();

	if( !pGrass )
		return;

	SGPVertex_GRASS_Cluster tempData;

	CSGPTerrainChunk** pChunkEnd = pGrass->m_TerrainGrassChunks.end();
	for( CSGPTerrainChunk** pChunkStart = pGrass->m_TerrainGrassChunks.begin(); pChunkStart < pChunkEnd; pChunkStart++ )
	{
		if( !m_pRenderDevice->GetWorldSystemManager()->isTerrainChunkVisible( *pChunkStart ) )
			continue;

		for(uint32 i=0; i<(*pChunkStart)->GetGrassClusterDataCount(); i++ )
		{
			// None Flag, skip this Cluster
			uint32 nGrassSetFlag = (*pChunkStart)->GetGrassClusterData()[i].nData;
			if( nGrassSetFlag == 0 )
				continue;

			tempData.vPosition[0] = (*pChunkStart)->GetGrassClusterData()[i].fPositionX;
			tempData.vPosition[1] = (*pChunkStart)->GetGrassClusterData()[i].fPositionY;
			tempData.vPosition[2] = (*pChunkStart)->GetGrassClusterData()[i].fPositionZ;
			tempData.vPosition[3] = float( (nGrassSetFlag & 0x00FF0000) >> 16 );

			// GrassCluster is not inside the camera Frustum, skip this Cluster
			AABBox GrassClusterAABB;
			GrassClusterAABB += Vector3D(tempData.vPosition[0] - m_vDefaultGrassSize.x, tempData.vPosition[1], tempData.vPosition[2] - m_vDefaultGrassSize.x);
			GrassClusterAABB += Vector3D(tempData.vPosition[0] + m_vDefaultGrassSize.x, tempData.vPosition[1] + m_vDefaultGrassSize.y, tempData.vPosition[2] + m_vDefaultGrassSize.x);
			if( !GrassClusterAABB.Intersects(viewFrustum) )
				continue;

			// GrassCluster is too far from the Grass Far Fading distance, skip this Cluster
			float fGrassDis = (m_vCameraPos - Vector4D(tempData.vPosition[0], tempData.vPosition[1], tempData.vPosition[2])).GetLength();
			if( fGrassDis > CSGPWorldConfig::getInstance()->m_fGrassFarFadingEnd )
				continue;

			// Too many grass Cluster
			if( m_GrassClusterInstanceArray.size() + 1 > INIT_GRASSCLUSTERINSTANCE_NUM )
				continue;

			tempData.vPackedNormal[0] = (uint8)(((*pChunkStart)->GetGrassClusterData()[i].nPackedNormal & 0xFF000000) >> 24);
			tempData.vPackedNormal[1] = (uint8)(((*pChunkStart)->GetGrassClusterData()[i].nPackedNormal & 0x00FF0000) >> 16);
			tempData.vPackedNormal[2] = (uint8)(((*pChunkStart)->GetGrassClusterData()[i].nPackedNormal & 0x0000FF00) >> 8);
			tempData.vPackedNormal[3] = (uint8)((nGrassSetFlag & 0xFF000000) >> 24);

			tempData.vColor[0] = tempData.vColor[1] = tempData.vColor[2] = 1.0f;
			tempData.vColor[3] = 1.0f - jlimit(0.0f, 1.0f, (fGrassDis - CSGPWorldConfig::getInstance()->m_fGrassFarFadingStart) / (CSGPWorldConfig::getInstance()->m_fGrassFarFadingEnd - CSGPWorldConfig::getInstance()->m_fGrassFarFadingStart));
			
			tempData.vWindParams[0] = ((nGrassSetFlag & 0x0000FF00) >> 8) / 255.0f;
			tempData.vWindParams[1] = 0.0f;
			tempData.vWindParams[2] = (nGrassSetFlag & 0x000000FF) / 255.0f;
			tempData.vWindParams[3] = 0.0f;

			m_GrassClusterInstanceArray.add( tempData );
		}
	}

	// update grass rendering params
	m_vTimeParams.x += fDeltaTimeInSecond;
	m_vTimeParams.y = pGrass->m_fGrassPeriod;
	m_vLightMapTextureDimision.Set(
		1.0f / m_pRenderDevice->GetWorldSystemManager()->getTerrain()->GetTerrainWidth(),
		1.0f / m_pRenderDevice->GetWorldSystemManager()->getTerrain()->GetTerrainWidth() );
	m_vWindDirForce = pGrass->m_vWindDirectionAndStrength;
}
开发者ID:phoenixzz,项目名称:SGPEngine,代码行数:70,代码来源:sgp_OpenGLGrassRenderer.cpp


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