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


C++ ray::type方法代码示例

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


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

示例1: intersect

bool Geometry::intersect(const ray&r, isect&i) const {
	double tmin, tmax;
	if (hasBoundingBoxCapability() && !(bounds.intersect(r, tmin, tmax))) return false;
	// Transform the ray into the object's local coordinate space
	Vec3d pos = transform->globalToLocalCoords(r.getPosition());
	Vec3d dir = transform->globalToLocalCoords(r.getPosition() + r.getDirection()) - pos;
	double length = dir.length();
	dir /= length;

	ray localRay( pos, dir, r.type() );

	if (intersectLocal(localRay, i)) {
		// Transform the intersection point & normal returned back into global space.
		i.N = transform->localToGlobalCoordsNormal(i.N);
		i.t /= length;
		return true;
	} else return false;
}
开发者ID:HenrYxZ,项目名称:GraphicsII,代码行数:18,代码来源:scene.cpp

示例2: getColor

Vec3d CubeMap::getColor(ray r) const {

	int axis, front, left, right, top, bottom;
	double u,v;
	Vec3d dir = r.getDirection();
	
	if (fabs(dir[0]) > fabs(dir[1]))
		if (fabs(dir[0]) > fabs(dir[2])) {
			axis = 0;
			bottom = 3;
			top = 2;
			if (dir[0] > 0.0) {
				front = 0;
				left = 4;
				right = 5;
			}
			else {
				front = 1;
				left = 5;
				right = 4;
			}
		}
		else {
			axis = 2;
			bottom = 3;
			top = 2;
			if (dir[2] > 0.0) {
				front = 5;
				left = 0;
				right = 1;
			}
			else {
				front = 4;
				left = 1;
				right = 0;
			}
		}
	else
		if (fabs(dir[1]) > fabs(dir[2])) {
			axis = 1;
			left = 1;
			right = 0;
			if (dir[1] > 0.0) {
				front = 2;
				bottom = 4;
				top = 5;
			}
			else {
				front = 3;
				bottom = 5;
				top = 4;
			}
		}
		else {
			axis = 2;
			bottom = 3;
			top = 2;
			if (dir[2] > 0.0) {
				front = 5;
				left = 0;
				right = 1;
			}
			else {
				front = 4;
				left = 1;
				right = 0;
			}
		}

	if (axis == 0) {
		u = dir[2]/dir[0];
		if (dir[0] > 0.0) v = dir[1]/dir[0];
		else v = -dir[1]/dir[0];
	}
	else if (axis == 1) {
		if (dir[1] > 0.0) u = dir[0]/dir[1];
		else u = -dir[0]/dir[1];
		v = dir[2]/dir[1];
	}
	else if (axis == 2) {
		u = -dir[0]/dir[2];
		if (dir[2] > 0.0) v = dir[1]/dir[2];
		else v = -dir[1]/dir[2];
	}

	u = (u + 1.0)/2.0;
	v = (v + 1.0)/2.0;

	int filterwidth = traceUI->getFilterWidth();
	if (r.type() != ray::VISIBILITY || filterwidth == 1) return tMap[front]->getMappedValue(Vec2d(u, v));
	int fw = (filterwidth + 1)/2 - 1;
	int rm = filterwidth - fw;
	int width = tMap[front]->getWidth();
	int height = tMap[front]->getHeight();
	double delu = 1.0/width;
	double delv = 1.0/height;
	int x = floor(0.5 + u * (width - 1));
	int y = floor(0.5 + v * (height - 1));
	double startu = delu * (x - fw);
	double startv = delv * (y - fw);
//.........这里部分代码省略.........
开发者ID:kevino5233,项目名称:HackAway,代码行数:101,代码来源:cubeMap.cpp


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