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


C++ Geometry::GetType方法代码示例

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


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

示例1: report

// report function 
void report(Geometry &obj){

	cout << "----- Geometry Report -----\n";
	cout << "   Name:    " << obj.GetName() << endl;
	cout << "   Type:    " << obj.GetType() << endl; 
	cout << "   Volume:  " << obj.ComputeVolume()  << endl;
	cout << "   Surface: " << obj.ComputeSurface() << endl;
	cout << "---------------------------\n";
}
开发者ID:bogoli,项目名称:CS1410,代码行数:10,代码来源:Main.cpp

示例2: Raytrace

Geometry* Raytracer::Raytrace(Ray &r, Color &col, int depth, float &dist)
{
	if(depth > TRACEDEPTH)
		return NULL;
	dist = MAX_DIST;
	Vector intersection, L, N, V, R, sampleDir, samplePos;
	Geometry *geom = NULL;
	//int result = 0;
	int res;
	float dot, diff, spec, shade = 0.0f, ldist, rdist, tempdist, ambient;
	float step = 1.0f / lrflti(shadowQuality);
	Color diffuse, specular, reflection, accumulator;
	Ray shadow, ambientRay;
	bool inShade;

	//find the nearest intersection
	vector<Geometry *> &gv = sc->GetObjects();
	for(vector<Geometry *>::iterator git = gv.begin(); git != gv.end(); git++)
	{
		if((*git)->GetType() == Geometry::BVHACCEL)
		{
			BVH *bvh = static_cast<BVH *>(*git);
			Geometry *ng = NULL;
			res = bvh->IntersectRecursive(r, dist, &ng);
			if(res)
			{
				geom = ng;
			}
		}
		else
		{
			res = (*git)->Intersect(r, dist);
			if(res)
			{
				geom = *git;
				//result = res;
			}
		}
	}

	//if there's no hit, terminate the ray
	if(!geom)
		return NULL;

	if(geom->IsLight())
	{
		col = geom->GetMaterial().GetColor() * geom->GetLightIntensity();
	}
	else
	{
		//determine the point of intersection
		intersection = r.origin + (r.direction * dist);

		//accumulate the lighting
		vector<Geometry *> &lov = sc->GetObjects();
		for(vector<Geometry *>::iterator lit = lov.begin(); lit != lov.end(); lit++)
		{
			if(((*lit)->IsLight()) && ((*lit)->GetType() == Geometry::SPHERE))
			{
				L = ((Sphere *)(*lit))->GetPosition() - intersection;
				ldist = L.Length();
				L /= ldist;

				if(geom->GetType() == Geometry::SDFUNC)
				{
					N = geom->GetNormal(intersection);
					shadow.origin = intersection + N * (10.0f * EPSILON);
				}
				else
				{
					shadow.origin = intersection + L * EPSILON;
				}

				//shadow
				if(shadowQuality == 1)
				{
               Geometry *lcache = (*lit)->GetLightCacheItem(omp_get_thread_num());
					shade = 1.0f;

					shadow.direction = L;
               
               //try shadow cache first
               bool lightCacheHit = false;
               if(lcache && (lcache->Intersect(shadow, ldist)))
               {
                  lightCacheHit = true;
                  shade = 0.0f;
               }

               //now iterate through the geometry
               if(!lightCacheHit)
               {
                  vector<Geometry *> &sov = sc->GetObjects();
                  for(vector<Geometry *>::iterator sit = sov.begin(); sit != sov.end(); sit++)
                  {
                     if((*sit != *lit) && (*sit != lcache) && ((*sit)->Intersect(shadow, ldist)))
                     {
                        (*lit)->SetLightCacheItem(*sit, omp_get_thread_num());
                        shade = 0.0f;
                        break;
//.........这里部分代码省略.........
开发者ID:ReaperUnreal,项目名称:Raytracer,代码行数:101,代码来源:raytracer.cpp


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