本文整理汇总了C++中Primitive::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Primitive::getName方法的具体用法?C++ Primitive::getName怎么用?C++ Primitive::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Primitive
的用法示例。
在下文中一共展示了Primitive::getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalnDiffusion
Color Raytracer::CalnDiffusion( Collider* collider , int* hash, int rc, Color weight) {
Primitive* pri = collider->GetPrimitive();
Color color = pri->GetMaterial()->color;
if (pri->GetMaterial()->texture != NULL)
{
if (pri->getName() == 0)
color = color * pri->GetTexture(collider->C);
else
color = color * pri->GetTexture(Vector3(collider->u, collider->v, 0));
}
Color ret = color * scene->GetBackgroundColor() * pri->GetMaterial()->diff;
for ( Light* light = scene->GetLightHead() ; light != NULL ; light = light->GetNext() )
ret += color * light->GetIrradiance( collider , scene->GetPrimitiveHead() , scene->GetCamera()->GetShadeQuality() , hash );
if (camera->GetAlgorithm() == "PM")
ret += color * photonmap->GetIrradiance( collider , camera->GetSampleDist() , camera->GetSamplePhotons() );
if (camera->GetAlgorithm() == "PPM" || camera->GetAlgorithm() == "SPPM") {
Hitpoint hitpoint;
hitpoint.pos = collider->C;
hitpoint.dir = collider->I;
hitpoint.N = collider->N;
hitpoint.primitive = collider->GetPrimitive();
hitpoint.rc = rc;
hitpoint.weight = weight * color;
hitpoint.R2 = photonmap->GetRadius2(collider, camera->GetSampleDist(), camera->GetSamplePhotons());
hitpointMap->Store(hitpoint);
}
return ret;
}
示例2: render
bool Engine::render(void)
{
std::ofstream debugfile;
debugfile.open("E:\\code\\debug2.txt", std::ios_base::app);
debugfile << "Starting currLine = " << currLine << std::endl;
// render scene
Vector3 o(0.0, 0.0, -5.0);
// initialize timer
unsigned int msecs = get_msec();
// reset last found primitive pointer
Primitive *lastprim = nullptr;
// render remaining lines
for (unsigned int y = currLine; y < (height - 20); y++)
{
SX = WX1;
// render pixels for current line
for (unsigned int x = 0; x < width; x++)
{
// fire primary ray
Color acc(0.0, 0.0, 0.0);
Vector3 dir = Vector3(SX, SY, 0) - o;
dir.normalize();
Ray r(o, dir);
double dist;
unsigned int prev = get_msec();
Primitive *prim = raytrace(r, acc, 1, 1.0, dist);
unsigned int post = get_msec();
if (post - prev != 0) {
if (prim)
debugfile << prim->getName() << " @ ";
debugfile << x << ", " << y << ": ";
debugfile << post - prev << std::endl;
}
int red = (int)(acc.R() * 256);
int green = (int)(acc.G() * 256);
int blue = (int)(acc.B() * 256);
if (red > 255) red = 255;
if (green > 255) green = 255;
if (blue > 255) blue = 255;
dest[ppos++] = RGBA_to_Pixel(red, green, blue);
SX += DX;
}
SY += DY;
// see if we've been working to long already
// TODO
if ((get_msec() - msecs) > 100)
{
// return control to windows so the screen gets updated
currLine = y + 1;
debugfile << "exiting currLine = " << currLine << std::endl;
debugfile.close();
return false;
}
}
// all done
debugfile.close();
return true;
}