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


C++ vec3::Y方法代码示例

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


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

示例1: if

int	ComputeBoxVisibility(const vec3& min, const vec3& max, const ViewState& s, int ClipHint)
// Returns a visibility code indicating whether the axis-aligned box defined by {min, max} is
// completely inside the frustum, completely outside the frustum, or partially in.
// The return value corresponds to ClipHint.  The first six bits in ClipHint correspond
// to flags for each frustum plane; if a bit is set, that means the box is known to
// be inside the corresponding plane, so no additional test is needed.
{
	// Doesn't do a perfect test for NOT_VISIBLE.  Checks each
	// box vertex against each frustum plane.
	
	// Check each vertex of the box against the view frustum, and compute
	// bit codes for whether the point is outside each plane.
	int	OrCodes = 0, AndCodes = ~0;

	for (int i = 0; i < 8; i++) {
		
		vec3	v(min), w;
		if (i & 1) v.SetX(max.X());
		if (i & 2) v.SetY(max.Y());
		if (i & 4) v.SetZ(max.Z());
		
		s.ViewMatrix.Apply(&w, v);	// May need to pull matrix out of gl

		// Now check against the frustum planes.
		int	Code = ClipHint;
		int	Bit = 1;
		for (int j = 0; j < 6; j++, Bit <<= 1) {
			if ((ClipHint & Bit) == 0) {
				if (w * s.ClipPlane[j].Normal > s.ClipPlane[j].D) {
					// The point is inside this plane.
					Code |= Bit;
				}
			}
		}

		OrCodes |= Code;
		AndCodes &= Code;
	}

	// Based on bit-codes, return culling results.
	if (OrCodes != 0x3F) {
		// All verts are outside (at least) one of the planes.
		return NOT_VISIBLE;
	} else if (AndCodes == 0x3F) {
		// All verts are inside all planes.
		return NO_CLIP;
	} else {
		// All verts possibly inside some planes.
		return AndCodes;
	}
}
开发者ID:Echelon9,项目名称:soulride,代码行数:51,代码来源:clip.cpp


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