本文整理汇总了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";
}
示例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;
//.........这里部分代码省略.........