本文整理汇总了C++中SimpleCamera::GetPos方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleCamera::GetPos方法的具体用法?C++ SimpleCamera::GetPos怎么用?C++ SimpleCamera::GetPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleCamera
的用法示例。
在下文中一共展示了SimpleCamera::GetPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculate_pixel
bool calculate_pixel(float x, float y, task_detail_t *task, batch_blob_t *datablob, pixel_data_t *pixel)
{
// Clear pixel
Pxf::Math::Vec3f fpixel(0.0f, 0.0f, 0.0f);
fpixel.r = 0.0f;
fpixel.g = 0.0f;
fpixel.b = 0.0f;
SimpleCamera* cam = (SimpleCamera*) datablob->cam;
// Center ray
Vec3f screen_coords(-1.0f + x, 1.0f - y,0.0f);
ray_t cray;
cray.o = Vec3f(0.0f,0.0f,1.41421356f);
cray.o += cam->GetPos();
Quaternion orientation = (*cam->GetOrientation());
Normalize(orientation);
//screen_coords = orientation * screen_coords;
//Normalize(screen_coords);
screen_coords += cam->GetPos();
/*
if (!calc_multisample_ray(&cray, datablob, &fpixel, 0.001f, 0))
{
Pxf::Message("calculate_pixel", "Ray shooting failed!");
return false;
}*/
// find closest primitive
for(int pixel_x = 0; pixel_x < datablob->samples_per_pixel; ++pixel_x)
{
for(int pixel_y = 0; pixel_y < datablob->samples_per_pixel; ++pixel_y)
{
// Offset ray
ray_t ray = cray;
Vec3f new_screen_coords = screen_coords;
// TODO: Make sampling more non-uniform
//new_screen_coords.x += (1.0f / ((float)datablob->pic_w * (float)datablob->samples_per_pixel)) * (float)pixel_x;
//new_screen_coords.y += (1.0f / ((float)datablob->pic_h * (float)datablob->samples_per_pixel)) * (float)pixel_y;
new_screen_coords.x += (0.5f / ((float)datablob->pic_w)) * (datablob->samples[rand() % 255] * 2.0f - 1.0f);
new_screen_coords.y += (0.5f / ((float)datablob->pic_h)) * (datablob->samples[rand() % 255] * 2.0f - 1.0f);
ray.d = new_screen_coords - cray.o;
ray.d = orientation * ray.d;
Normalize(ray.d);
// Calc direct light
Pxf::Math::Vec3f light_contrib;
if (!calc_ray_contrib(&ray, datablob, &light_contrib, 0))
{
Pxf::Message("calculate_pixel", "Light calculations failed!");
return false;
}
fpixel += light_contrib;
}
}
fpixel /= datablob->samples_per_pixel * datablob->samples_per_pixel;
fpixel.x = Pxf::Math::Clamp(fpixel.x, 0.0f, 1.0f);
fpixel.y = Pxf::Math::Clamp(fpixel.y, 0.0f, 1.0f);
fpixel.z = Pxf::Math::Clamp(fpixel.z, 0.0f, 1.0f);
pixel->r = (unsigned char)(fpixel.r * 255.0f);
pixel->g = (unsigned char)(fpixel.g * 255.0f);
pixel->b = (unsigned char)(fpixel.b * 255.0f);
return true;
}