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


C++ CCoreDispInfo::GetPositionOnSurface方法代码示例

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


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

示例1: EmitDetailObjectsOnDisplacementFace

//-----------------------------------------------------------------------------
// Places Detail Objects on a face
//-----------------------------------------------------------------------------
static void EmitDetailObjectsOnDisplacementFace( dface_t* pFace, 
						DetailObject_t& detail, CCoreDispInfo& coreDispInfo )
{
	assert(pFace->numedges == 4);

	// We're going to pick a bunch of random points, and then probabilistically
	// decide whether or not to plant a detail object there.

	// Compute the area of the base face
	float area = ComputeDisplacementFaceArea( pFace );

	// Compute the number of samples to take
	int numSamples = area * detail.m_Density * 0.000001;

	// Now take a sample, and randomly place an object there
	for (int i = 0; i < numSamples; ++i )
	{
		// Create a random sample...
		float u = rand() / (float)RAND_MAX;
		float v = rand() / (float)RAND_MAX;

		// Compute alpha
		float alpha;
		Vector pt, normal;
		coreDispInfo.GetPositionOnSurface( u, v, pt, &normal, &alpha );
		alpha /= 255.0f;

		// Select a group based on the alpha value
		int group = SelectGroup( detail, alpha );

		// Now that we've got a group, choose a detail
		int model = SelectDetail( detail.m_Groups[group] );
		if (model < 0)
			continue;

		// Got a detail! Place it on the surface...
		PlaceDetail( detail.m_Groups[group].m_Models[model], pt, normal );
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:42,代码来源:detailobjects.cpp


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