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


C++ CArea::GetRadius方法代码示例

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


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

示例1: CreateRandomDensityMap


//.........这里部分代码省略.........
		work = density + i + (i * width);
		for(x = i; x < width - i; x++, work++)
		{
			*work += (byte)common->irand(inc >> 1, inc);
		}

		// Left and right edges
		work = density + i + ((i + 1) * width);
		work2 = density + (width - i) + ((i + 1) * width);
		for(y = i + 1; y < height - i - 2; y++, work += width, work2 += width)
		{
			*work += (byte)common->irand(inc >> 1, inc);
			*work2 += (byte)common->irand(inc >> 1, inc);
		}

		// Bottom line
		work = density + i + ((height - i - 1) * width);
		for(x = i; x < width - i; x++, work++)
		{
			*work += (byte)common->irand(inc >> 1, inc);
		}
	}
*/
	count = 0;

	for(y=0;y<height;y++)
	{
		for(x=0;x<width;x++,densityPos++)
		{
			xpos = (x * hm_width / width);
			ypos = (y * hm_height / height);
			ypos = hm_height - ypos - 1;

			if (hm_map[ypos*hm_width + xpos] < 150)
			{
				continue;
			}

			foundUneven = false;
			for(dx=-4;(dx<=4 && !foundUneven);dx++)
			{
				for(dy=-4;(dy<=4 && !foundUneven);dy++)
				{
					if (dx == 0 && dy == 0)
					{
						continue;
					}
					if ((xpos+dx) >= 0 && (xpos+dx) < hm_width && (ypos+dy) >= 0 && (ypos+dy) < hm_height)
					{
						if (hm_map[(ypos+dy)*hm_width + (xpos+dx)] < 190)
						{
							*densityPos = 205;
							count++;
							foundUneven = true;
						}
					}
				}
			}
		}
	}

/*	FILE	*FH;

	FH = fopen("c:\o.raw", "wb");
	fwrite(hm_map, 1, common->GetRealWidth() * common->GetRealHeight(), FH);
	fclose(FH);

	FH = fopen("c:\d.raw", "wb");
	fwrite(density, 1, width*height, FH);
	fclose(FH);
*/
	// Reduce severely for any settlements/buildings/objectives
	VectorScale(common->GetSize(), 1.0f / width, derxelSize);

	origin_land = common;
	area = common->GetFirstArea();
	while(area)
	{
		// Skip group types since they encompass to much open area
		if ( area->GetType ( ) == AT_GROUP )
		{
			area = common->GetNextArea();
			continue;
		}

		VectorSubtract(area->GetPosition(), common->GetMins(), pos);
		VectorInverseScaleVector(pos, derxelSize, dmappos);
		// Damn upside down gensurf
		dmappos[1] = height - dmappos[1];

		count = ceilf(area->GetRadius() / derxelSize[1]);

		while(count > 0)
		{
			CM_CircularIterate(density, width, height, dmappos[0], dmappos[1], 0, count, NULL, CG_Decrease);
			count--;
		}
		area = common->GetNextArea();
	}
}
开发者ID:Yberion,项目名称:j54fd1qs,代码行数:101,代码来源:RM_Terrain.cpp


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