コード例 #1
0
ファイル: BSPMapData.cpp プロジェクト: HermanHGF/amorphous
void CBSPMapData::SetLightsFromLightSourceFaces()
{
	vector<CMapFace> vecTempLightSourceFace;	// temporary buffer to hold light source faces
	size_t i,j;
	size_t iNumInteriorFaces = m_aInteriorFace.size();

	for(i=0; i<iNumInteriorFaces; i++)
	{	// set all the flags of light source faces to false
		m_aInteriorFace[i].m_bFlag = false;
	}

	// cluster light source faces	
	for(i=0; i<iNumInteriorFaces; i++)
	{
		vecTempLightSourceFace.clear();
		CMapFace& rFace1 = m_aInteriorFace[i];

		if( !rFace1.ReadTypeFlag(CMapFace::TYPE_LIGHTSOURCE) )
			continue;	// doesn't emit light by itself

		if( rFace1.m_bFlag == true )
			continue;	// already registered as a light source face

		rFace1.m_bFlag = true;
		vecTempLightSourceFace.push_back( rFace1 );

		// adjacent light source faces are converted into one point light
		SearchAdjacentLightSourceFaces_r( &vecTempLightSourceFace, rFace1, &m_aInteriorFace );

		// convert each cluster of light source faces into a point light
		AABB3 aabb;
		aabb.Nullify();
		for(j=0; j<vecTempLightSourceFace.size(); j++)
			vecTempLightSourceFace[j].AddToAABB( aabb );

		SPointLightDesc light = FindPointLightDesc( rFace1.m_acSurfaceName );
		CPointLight* pPointLight = new CPointLight;
		pPointLight->vPosition = aabb.GetCenterPosition();
		pPointLight->Color.fRed   = light.fRed;
		pPointLight->Color.fGreen = light.fGreen;
		pPointLight->Color.fBlue  = light.fBlue;
		pPointLight->fIntensity   = light.fIntensity;
		pPointLight->fAttenuation0 = light.fAttenuation[0];
		pPointLight->fAttenuation1 = light.fAttenuation[1];
		pPointLight->fAttenuation2 = light.fAttenuation[2];
		m_vecpLight.push_back( pPointLight );
	}
}
コード例 #2
0
ファイル: Camera.hpp プロジェクト: HermanHGF/amorphous
inline bool Camera::ViewFrustumIntersectsWith( const AABB3& raabb ) const
{
	int i;
	float d;

	Vector3 vCenter, vExtents;
	vCenter = raabb.GetCenterPosition();
	vExtents = raabb.GetExtents();

	for( i=0; i<6; i++ )
	{
		const SPlane& rPlane = m_WorldBSPTree[i].plane;

		d = Vec3Dot( rPlane.normal, vCenter ) - rPlane.dist - raabb.GetRadiusForPlane(rPlane);

		if(0 < d)
			return false;
	}
	return true;
}