カメラの「目」からカメラの目から少し離れた表示面まで光線を生成するコードを作成しました。
R3Ray ConstructRayThroughPixel(...)
{
R3Point p;
double increments_x = (lr.X() - ul.X())/(double)width;
double increments_y = (ul.Y() - lr.Y())/(double)height;
p.SetX( ul.X() + ((double)i_pos+0.5)*increments_x );
p.SetY( lr.Y() + ((double)j_pos+0.5)*increments_y );
p.SetZ( lr.Z() );
R3Vector v = p-camera_pos;
R3Ray new_ray(camera_pos,v);
return new_ray;
}
ul
は表示面の左上隅であり、は表示面lr
の左下隅です。それらは次のように定義されます。
R3Point org = scene->camera.eye + scene->camera.towards * radius;
R3Vector dx = scene->camera.right * radius * tan(scene->camera.xfov);
R3Vector dy = scene->camera.up * radius * tan(scene->camera.yfov);
R3Point lr = org + dx - dy;
R3Point ul = org - dx + dy;
ここで、org
はradius
ビューイングプレーンとカメラアイの間の距離であるビューイングプレーンの中心でdx
ありdy
、ビューイングプレーンの中心からのxおよびy方向の変位です。
このConstructRayThroughPixel(...)
関数は、目が(0,0,0)にあるカメラに対して完全に機能します。ただし、カメラが別の位置にある場合、画像に必要なすべての光線が生成されるわけではありません。
何がうまくいかない可能性がある提案はありますか?たぶん私の方程式に何か問題がありますか?
助けてくれてありがとう。