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


C++ AbstractObject::getIOR方法代码示例

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


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

示例1: scatter

	Ray HeterogeneousVolume::scatter(Ray &inRay) const{
		Ray outRay;
		outRay.isDeltaDirection = false;

		bool go_in_vol = inRay.intersectObj == this && inRay.insideObj != this;
		bool be_in_vol = inRay.insideObj == this;

		// CASE1: Go in volume.
		if(go_in_vol){
			vec3f position = inRay.origin + inRay.direction*inRay.intersectDist;
			vec3f normal = inRay.intersectObj->getWorldNormal(inRay.intersectTriangleID, position);

			outRay.origin = position;
			outRay.direction = inRay.direction;

			vec3f reflDir = -normal.dot(inRay.direction)*normal*2 + inRay.direction;
			reflDir.normalize();
			float theta = acos(inRay.direction.dot(normal));

			AbstractObject* currentInsideObject = inRay.insideObj;
			AbstractObject* outSideObject = (AbstractObject*)this;

			float current_n = currentInsideObject ? currentInsideObject->getIOR() : 1;
			float next_n = outSideObject ? outSideObject->getIOR() : 1;
			float sin_phi = current_n / next_n * sin(theta);

			outRay.intersectObj = NULL;
			outRay.radiance = vec3f(1, 1, 1);
			outRay.directionProb = 1;
			outRay.contactObj = (AbstractObject*)this;
			outRay.contactTriangleID = inRay.intersectTriangleID;

			if(sin_phi > 1){
				outRay.direction = reflDir;
				outRay.insideObj = inRay.insideObj;
				outRay.directionProb = 1;
				outRay.isDeltaDirection = true;
				outRay.photonType = Ray::NOUSE;
			}
			else{
				float phi = asin(sin_phi);
				if(theta > PI/2)	phi = PI - phi;
				vec3f axis = normal.cross(inRay.direction);
				axis.normalize();
				outRay.direction = vec3f(RotateMatrix(axis, phi) * vec4f(normal, 0));
				outRay.direction.normalize();

				float cos_theta = abs(cos(theta));
				float cos_phi = abs(cos(phi));
				float esr = powf(abs(current_n*cos_theta-next_n*cos_phi)/(current_n*cos_theta+next_n*cos_phi),2);
				float epr = powf(abs(next_n*cos_theta-current_n*cos_phi)/(next_n*cos_theta+current_n*cos_phi),2);
				float er = (esr+epr)/2;
				float p = er;

				if(rng->genFloat() < p)
				{
					outRay.direction = reflDir;
					outRay.radiance *= er / outRay.cosineTerm();
					outRay.directionProb = p;
					outRay.insideObj = inRay.insideObj;
					outRay.isDeltaDirection = true;
					outRay.photonType = Ray::NOUSE;
				}
				else
				{
					outRay.radiance *= (1-er) / outRay.cosineTerm();
					outRay.directionProb = 1-p;
					outRay.contactObj = outRay.insideObj = (AbstractObject*)this;
					outRay.isDeltaDirection = true;
					outRay.photonType = Ray::HITVOL;
				}
				outRay.direction.normalize();
			}
			return outRay;
		}

		float p_medium, P_surface, sampleDist;

		bool samplingState = sampleDistance(inRay, sampleDist, p_medium, P_surface);

		bool out_of_vol = samplingState == false;//sampleDist >= inRay.intersectDist;

		// CASE2: Be in volume.
		if(be_in_vol && !out_of_vol){
			outRay.origin = inRay.origin + inRay.direction * sampleDist;
			outRay.radiance = bsdf->sampleBSDF(inRay.direction, outRay.direction, vec3f(), *rng, &outRay.directionProb);
			outRay.insideObj = (AbstractObject*)this;
			outRay.contactTriangleID = inRay.intersectTriangleID;
			float albedo = isSubsurface ? getAlbedo(outRay.origin) : getAlbedo();
			float rander = rng->genFloat();	
			if(rander < albedo){
				outRay.contactObj = NULL;
				outRay.directionProb *= albedo;
				outRay.originProb = p_medium;//  pMedium(inRay, sampleDist);// 
				outRay.isDeltaDirection = false;
				outRay.radiance *= isSubsurface ? lookUpSubSurfaceVolumeData(outRay.origin, SCATTERING) : scatteringCoeff * lookUpDensity(outRay.origin);
				outRay.photonType = Ray::INVOL;
			}
			else{
				// terminate
//.........这里部分代码省略.........
开发者ID:luanfujun,项目名称:WalkRay,代码行数:101,代码来源:HeterogeneousVolume.cpp


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