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


C++ HeightMap::fillStyle方法代码示例

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


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

示例1: matrixImgToGrid

void VoxelGrid::
paintHeightMap(const GridDescription & gridDesc,
	const HeightMap & instruction)
{
	Rect3i yeeRect = instruction.yeeRect();
	Vector3i u1 = instruction.rowDirection();
	Vector3i u2 = -instruction.columnDirection();
	Vector3i u3 = instruction.upDirection();
	
	int nUp = abs(dot(u3, yeeRect.p2-yeeRect.p1)) + 1;
	
	Mat3i matrixImgToGrid(Mat3i::withColumns(u1,u2,u3));
	
	// this will select the correct corner of the fill rect regardless of the
	// direction of the image unit vectors.  This point corresponds to the
	// origin of the image (top-left pixel of the .bmp or .*).
	Vector3i fillOrigin = clip(yeeRect,
		Vector3i(-100000*u1 + -100000*u2 + -100000*u3) );
	
	// now the image!
	Magick::Image heightMap;
	try {
		heightMap.read(instruction.imageFileName());
		FillStyle style = instruction.fillStyle();
		Paint* paint = Paint::paint(instruction.material());
		
		// iterate over rows and columns of the image; extrude into grid
		for (unsigned int row = 0; row < heightMap.rows(); row++)
		for (unsigned int col = 0; col < heightMap.columns(); col++)
		{
			Magick::ColorGray color = heightMap.pixelColor(col, row);
			int height = int(double(nUp)*color.shade());
			
			Vector3i p = fillOrigin + matrixImgToGrid*Vector3i(col, row, 0);
			for (int up = 0; up < height; up++)
			{
				Vector3i pGrid = p + u3*up;
				if (style == kPECStyle)
					paintPEC(paint, pGrid[0], pGrid[1], pGrid[2]);
				else if (style == kPMCStyle)
					paintPMC(paint, pGrid[0], pGrid[1], pGrid[2]);
                else
                    paintYeeCell(paint, pGrid[0], pGrid[1], pGrid[2]);
			}
		}
	} catch (Magick::Exception & magExc) {
		cerr << "Error reading HeightMap.  Maybe a file type issue?\n";
		cerr << "Caught ImageMagick exception " << magExc.what() << endl;
		LOG << "Exception logged.  Exiting.\n";
		exit(1);
	}
}
开发者ID:plisdku,项目名称:trogdor,代码行数:52,代码来源:VoxelGrid.cpp


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