コード例 #1
0
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool CVRADDispColl::Create( CCoreDispInfo *pDisp )
{
	// Base class create.
	if( !CDispCollTree::Create( pDisp ) )
		return false;

	// Allocate VRad specific memory.
	m_aLuxelCoords.SetSize( GetSize() );
	m_aVertNormals.SetSize( GetSize() );

	// VRad specific base surface data.
	CCoreDispSurface *pSurf = pDisp->GetSurface();
	m_iParent = pSurf->GetHandle();

	// VRad specific displacement surface data.
	for ( int iVert = 0; iVert < m_aVerts.Count(); ++iVert )
	{
		pDisp->GetNormal( iVert, m_aVertNormals[iVert] );
		pDisp->GetLuxelCoord( 0, iVert, m_aLuxelCoords[iVert] );
	}

	// Re-calculate the lightmap size (in uv) so that the luxels give
	// a better world-space uniform approx. due to the non-linear nature
	// of the displacement surface in uv-space
	dface_t *pFace = &g_pFaces[m_iParent];
	if( pFace )
	{
		CalcSampleRadius2AndBox( pFace );	
	}

	return true;
}
コード例 #2
0
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool CVRADDispColl::Create( CCoreDispInfo *pDisp )
{
	// save the face index for later reference
	CCoreDispSurface *pSurf = pDisp->GetSurface();
	m_ndxParent = pSurf->GetHandle();

	// save the size of the displacement surface
	m_Power = pDisp->GetPower();

	// save the displacement to base face point offset
	m_PointOffset = pSurf->GetPointStartIndex();

	//
	// get base surface points and normals
	//
	int i;
	m_PointCount = pSurf->GetPointCount();
	for( i = 0; i < m_PointCount; i++ )
	{
		Vector point, normal;
		pSurf->GetPoint( i, point );
		pSurf->GetPointNormal( i, normal );

		m_Points[i].Init( point[0], point[1], point[2] );
		m_PointNormals[i].Init( normal[0], normal[1], normal[2] );
	}

	// create the collision data
	if( !CDispCollTree::Create( pDisp ) )
		return false;

	// Set up the luxel data
	m_pLuxelCoords = new Vector2D[GetSize()];
	assert( m_pLuxelCoords );
	for ( i = GetSize(); --i >= 0; )
	{
		pDisp->GetLuxelCoord( 0, i, m_pLuxelCoords[i] );	
	}


	//
	// re-calculate the lightmap size (in uv) so that the luxels give
	// a better world-space uniform approx. due to the non-linear nature
	// of the displacement surface in uv-space
	//
	dface_t *pFace = &dfaces[m_ndxParent];
	if( pFace )
	{
		CalcSampleRadius2AndBox( pFace );	
	}

	//
	// create the vrad specific node data - build for radiosity transfer,
	// don't create for direct lighting only!
	//
	m_pVNodes = new VNode_t[m_NodeCount];
	if( !m_pVNodes )
		return false;
	
	BuildVNodes();

	return true;
}