Public Member Functions | |
const char * | Class () |
rTriangle (const GeoInfo *info, const Primitive *p) | |
rTriangle (const rTriangle &) | |
rPrimitive * | duplicate () const |
bool | add_to_render (Scene *, PrimitiveContext *) |
bool | add_to_displacement_render (Scene *, PrimitiveContext *) |
bool | intersect (float x, float y) const |
bool | intersect (float x, float y, float *dist) const |
bool | intersect_dist_squared (float x, float y, float *dist_squared) const |
bool | intersect_scanline (float y, int &X, int &R, VArray &out, VArray &du, VArray &dv) const |
float | trace (Scene *) |
float | distance (float x, float y) const |
float | distance_squared (float x, float y) const |
void | subdivide (std::vector< rPrimitive * > &primitives, SubdivisionContext *stx) |
rPrimitiveType | getPrimitiveType () const |
Public Attributes | |
VArray | v [3] |
in SCREEN coordiantes, w_normalized!!! | |
float | Ax |
float | Ay |
float | Bx |
float | By |
float | Nz |
For figuring out derivatives. |
Constructor.
Referenced by add_to_render().
rTriangle::rTriangle | ( | const rTriangle & | b | ) |
Copy constuctor.
bool rTriangle::add_to_render | ( | Scene * | scene, | |
PrimitiveContext * | ptx | |||
) | [virtual] |
Transform this triangle into homogeneous clipping space. Add any sub-triangles to the rendering scene. There's no need to further break a triangle down unless it intersects one of the frustum planes. Lastly we apply the homogeneous division by W which applies perspective to the points and places them into NDC space(Normalized Device Coordinates). This must be done AFTER clipping to guarantee that W is always > 0.
Clip the triangle against the frustum(W) near plane. There's two possibilities: a) One vertex is outside the plane. The triangle needs one additional edge defining the plane intersection line. To keep it a triangle we interpolate both vertices to the plane, and create one additional triangle primitive:
| 1 | 1 | /\ | /\ |/ \ 0 |/ \ | \ | A \ /| \ ---> 1 |\ \ /X| \ | \ \ /XX| \ | \ \ /XXX| \ | B \ \ 0 ----|--------- 2 0 |--------- 2 | |
b) Two vertices are outside the plane, so the outside edge is simply interpolated to the plane:
1 | | /\ | | /XX\ | | /XXXX\| | /XXXXXX| ---> | /XXXXXXX|\ 1 |\ /XXXXXXXX| \ | \ /XXXXXXXXX| \ | \ 0 ----------|--- 2 0 |--- 2 | |
Implements DD::Image::rPrimitive.
References add(), DD::Image::Scene::camera, DD::Image::eVelocityMotionVector, DD::Image::Scene::lens_func, DD::Image::Scene::max_tessellation(), DD::Image::VArray::MB(), DD::Image::Scene::mb_scene(), DD::Image::PrimitiveContext::mb_transforms(), DD::Image::Scene::mb_type(), DD::Image::VArray::P(), DD::Image::VArray::PL(), DD::Image::CameraOp::projection_is_linear(), DD::Image::Scene::projection_mode(), rTriangle(), DD::Image::Scene::time(), DD::Image::PrimitiveContext::transforms(), v, DD::Image::VArray::VEL(), DD::Image::VArray::w(), and DD::Image::Box3::w().
bool rTriangle::add_to_displacement_render | ( | Scene * | scene, | |
PrimitiveContext * | ptx | |||
) | [virtual] |
Transform this triangle into homogeneous clipping space. And add to the displacement map list in scene
Reimplemented from DD::Image::rPrimitive.
References DD::Image::Iop::displacement_bound(), DD::Image::PrimitiveContext::geoinfo(), DD::Image::Scene::lens_func, and DD::Image::GeoInfo::material.
bool rTriangle::intersect | ( | float | x, | |
float | y | |||
) | const [virtual] |
Intersect the screen-space projected triangle with an XY point, returning true if successful.
Implements DD::Image::rPrimitive.
References v, DD::Image::VArray::w(), DD::Image::VArray::x(), and DD::Image::VArray::y().
Referenced by distance().
bool rTriangle::intersect | ( | float | x, | |
float | y, | |||
float * | dist | |||
) | const [virtual] |
Intersect the screen-space projected triangle with an XY point. Return true it was successful, and assigns the distance to the nearest edge.
Implements DD::Image::rPrimitive.
References DD::Image::Box3::inside(), and intersect_dist_squared().
bool rTriangle::intersect_dist_squared | ( | float | x, | |
float | y, | |||
float * | dist_squared | |||
) | const [virtual] |
Intersect the screen-space projected triangle with an XY point. Return true it was successful, and assigns the square of the distance to the nearest edge.
Implements DD::Image::rPrimitive.
References DD::Image::Box3::inside(), MIN(), DD::Image::VArray::P(), and v.
Referenced by distance_squared(), and intersect().
bool rTriangle::intersect_scanline | ( | float | y, | |
int & | X, | |||
int & | R, | |||
VArray & | out, | |||
VArray & | du, | |||
VArray & | dv | |||
) | const [virtual] |
Intersect the triangle with a scanline. Return whether it was successful, and set X and R to the left and rightmost pixels affected, and set out to the value at 0,y (ie pixel 0 of the scanline, even if outside the triangle), and set du/dv to the screen-space derivatives, such that out+x*du is the value at any pixel in the scanline.
Implements DD::Image::rPrimitive.
References DD::Image::VArray::channels, fast_floor(), Nz, DD::Image::VArray::P(), DD::Image::VArray::UV(), v, DD::Image::Vector4::w, DD::Image::VArray::w(), DD::Image::VArray::x(), and DD::Image::VArray::y().
float rTriangle::trace | ( | Scene * | scene | ) | [virtual] |
Not implemented yet.
Implements DD::Image::rPrimitive.
float rTriangle::distance | ( | float | x, | |
float | y | |||
) | const [virtual] |
Distance to the nearest edge the object in screen-space. Returns 0 or negative if inside the object.
Implements DD::Image::rPrimitive.
References intersect().
float rTriangle::distance_squared | ( | float | x, | |
float | y | |||
) | const [virtual] |
Square of the distance to the nearest edge the object in screen-space. Returns 0 or negative if inside the object.
Implements DD::Image::rPrimitive.
References intersect_dist_squared().
©2009 The Foundry Visionmongers, Ltd. All Rights Reserved. |