| 379 | } |
| 380 | |
| 381 | Imath::Box2i Camera::renderRegion() const |
| 382 | { |
| 383 | V2i resolution = renderResolution(); |
| 384 | Box2i renderRegion = Box2i( V2i( 0 ), resolution ); |
| 385 | |
| 386 | if( getOverscan() ) |
| 387 | { |
| 388 | // convert offsets into pixel values and apply them to the render region |
| 389 | renderRegion.min -= V2i( |
| 390 | int( getOverscanLeft() * (float)resolution.x), |
| 391 | int( getOverscanBottom() * (float)resolution.y) |
| 392 | ); |
| 393 | |
| 394 | renderRegion.max += V2i( |
| 395 | int( getOverscanRight() * (float)resolution.x), |
| 396 | int( getOverscanTop() * (float)resolution.y) |
| 397 | ); |
| 398 | } |
| 399 | |
| 400 | |
| 401 | if( hasCropWindow() ) |
| 402 | { |
| 403 | const Box2f &cropWindow = getCropWindow(); |
| 404 | |
| 405 | // Note the flip in Y because cropWindow uses a RenderMan convention, but renderRegion |
| 406 | // uses the Gaffer image convention |
| 407 | Box2i cropRegion( |
| 408 | V2i( |
| 409 | (int)( round( resolution.x * cropWindow.min.x ) ), |
| 410 | resolution.y - (int)( round( resolution.y * cropWindow.max.y ) ) |
| 411 | ), |
| 412 | V2i( |
| 413 | (int)( round( resolution.x * cropWindow.max.x ) ), |
| 414 | resolution.y - (int)( round( resolution.y * cropWindow.min.y ) ) |
| 415 | ) |
| 416 | ); |
| 417 | |
| 418 | renderRegion.min.x = std::max( renderRegion.min.x, cropRegion.min.x ); |
| 419 | renderRegion.max.x = std::min( renderRegion.max.x, cropRegion.max.x ); |
| 420 | renderRegion.min.y = std::max( renderRegion.min.y, cropRegion.min.y ); |
| 421 | renderRegion.max.y = std::min( renderRegion.max.y, cropRegion.max.y ); |
| 422 | } |
| 423 | |
| 424 | return renderRegion; |
| 425 | } |
| 426 | |
| 427 | Imath::V2f Camera::calculateFieldOfView() const |
| 428 | { |