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


C++ ChunkManager::isTransparent方法代码示例

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


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

示例1: castRay

// TODO: Should this go in chunkManager?
bool castRay(const Camera& camera, const ChunkManager& chunkManager, Coordinate& currentBlock, Coordinate& lastBlock)
{
	glm::vec3 current = camera.eye;
	glm::vec3 gaze = camera.gaze();

	currentBlock = current;
	glm::vec3 fractional = glm::fract(current);

	// The direction of travel, in block coordinates
	Coordinate step(glm::sign(gaze));

	// The distance along gaze between consecutive blocks boundary
	glm::vec3 delta = glm::length(gaze) / glm::abs(gaze);

	// The distance along gaze to the first block boundary
	glm::vec3 distance;
	distance.x = gaze.x < 0 ? fractional.x : 1 - fractional.x;
	distance.y = gaze.y < 0 ? fractional.y : 1 - fractional.y;
	distance.z = gaze.z < 0 ? fractional.z : 1 - fractional.z;
	distance *= delta;

	do
	{
		// Travel the smallest distance necessary to hit the next block

		// Intersects x-wall first
		if (distance.x <= distance.y && distance.x <= distance.z)
		{
			lastBlock = currentBlock;
			current += distance.x * gaze;
			currentBlock.x += step.x;
			distance -= glm::vec3(distance.x);
			distance.x = delta.x;
		}
		else if (distance.y <= distance.x && distance.y <= distance.z)
		{
			lastBlock = currentBlock;
			current += distance.y * gaze;
			currentBlock.y += step.y;
			distance -= glm::vec3(distance.y);
			distance.y = delta.y;
		}
		else if (distance.z <= distance.x && distance.z <= distance.y)
		{
			lastBlock = currentBlock;
			current += distance.z * gaze;
			currentBlock.z += step.z;
			distance -= glm::vec3(distance.z);
			distance.z = delta.z;
		}
		else
		{
			// Numerical error?
			assert(false);
		}

		// Only look for intersections within a certain range of the camera
		if (glm::length(current - camera.eye) > MAX_TARGET_DISTANCE)
			return false;

	} while (chunkManager.isTransparent(currentBlock));

	return true;
}
开发者ID:max107,项目名称:mycraft,代码行数:65,代码来源:ray_caster.cpp


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