#include <TFRasterize.h>
Works kind of like an iterator, here is an example:
TriRasterInfo ri(imageSizeX, imageSizeY); for(...)/// for each triangle { ri.setTri(someTriangle); while(!ri.end()) { /// position of fragment is ri.x() and ri.y() /// you can interpolate values using the interp*() functions ++ri; /// increment to the next pixel } }
any structure that returns a point using "[]" will work as the triangle type, you could just use an array of vec3<>'s. TODO: make this work for c arrays of c arrays??
Definition at line 128 of file TFRasterize.h.
Public Types | |
typedef gutz::vec4< T > | Vec4 |
typedef gutz::vec3< T > | Vec3 |
typedef gutz::vec2< T > | Vec2 |
typedef gutz::ray3< T > | Ray3 |
typedef TT | Tri3 |
Public Member Functions | |
TriRasterInfo (int sx, int sy) | |
int | getSizeX () const |
int | getSizeY () const |
bool | end () const |
use it like an iterator!... kind of | |
TriRasterInfo & | operator++ () |
bool | setTri (Tri3 const *t) |
returns true if the triangle has NO renderable pixels returns false if the has any renderable pixels | |
Tri3 const * | getTri () const |
T | x () const |
T | y () const |
void | reset () |
int | getMinX () const |
get the minimum x for the CURRENT scan line (at y()) | |
int | getMinY () const |
get the starting scan line (min y pos) | |
int | getMaxX () const |
get the maximum x for the CURRENT scan line (at y()) | |
int | getMaxY () const |
get the ending scan line (max y pos) | |
int | getMaxX (T yp) const |
get the max x position in image for some scan line yp | |
int | getMinX (T yp) const |
get the min x position in image for some scanline yp | |
void | incY () |
increment y | |
void | incX () |
increment x | |
T | getAlpha (const T x, const T y) const |
T | getBeta (const T x, const T y) const |
T | getGamma (const T x, const T y) const |
void | setBary (const T x, const T y) |
update barycentric coordinates for the current x(),y() positions alpha, beta, gamma will be set based on x,y pos you give | |
bool | validBary () const |
quick check if current pos (x(),y()) is inside triangle | |
template<class VT> Vec4 | interp4 (const VT &v0, const VT &v1, const VT &v3) const |
interpolate a 4 vector using the current barycentric coordinates | |
template<class VT> Vec3 | interp3 (const VT &v0, const VT &v1, const VT &v2) const |
interpolate a 3 vector using the current barycentric coordinates | |
template<class VT> Vec2 | interp2 (const VT &v0, const VT &v1, const VT &v2) const |
interpolate a 2 vector using the current barycentric coordinates | |
template<class TP> TP | interp (const TP &v0, const TP &v1, const TP &v2) const |
< any type | |
bool | setUp (Tri3 const *t3) |
setup for rasterizaton, set the triangle being rasterized NOT FOR GENERAL USE, use setTri() | |
TriRasterInfo () | |
shouldn't create without a size!!! | |
T | intersectY (const T yp, const Ray3 &r) const |
T | intersect2D (const Ray3 &ri, const Ray3 &ro) const |
void | setupBary (const Vec3 &p0, const Vec3 &p1, const Vec3 &p2) |
Public Attributes | |
T | alpha |
public data | |
T | beta |
public data | |
T | gamma |
public data | |
T | yPos |
T | xPos |
int | minY |
min/max values for setting up loops | |
int | maxY |
int | minX |
int | maxX |
Tri3 const * | tri |
int | _sx |
image size: | |
int | _sy |
image size: | |
T | xa |
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca | |
T | ya |
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca | |
T | ac |
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca | |
T | xb |
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca | |
T | yb |
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca | |
T | bc |
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca | |
T | xg |
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca | |
T | yg |
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca | |
T | gc |
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca | |
int | se |
int | ee |
T | yswapStart |
T | yswapEnd |
Ray3 | r [3] |
|
Definition at line 133 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::setUp(). |
|
Definition at line 134 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getTri(), and TriRasterInfo< T, TT >::setUp(). |
|
Definition at line 132 of file TFRasterize.h. |
|
Definition at line 131 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::interp2(), and TriRasterInfo< T, TT >::interp3(). |
|
Definition at line 130 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::interp4(). |
|
Definition at line 136 of file TFRasterize.h. References TriRasterInfo< T, TT >::_sx, TriRasterInfo< T, TT >::_sy, TriRasterInfo< T, TT >::maxY, and TriRasterInfo< T, TT >::yPos. |
|
shouldn't create without a size!!!
Definition at line 415 of file TFRasterize.h. References TriRasterInfo< T, TT >::_sx, TriRasterInfo< T, TT >::_sy, TriRasterInfo< T, TT >::maxY, and TriRasterInfo< T, TT >::yPos. |
|
use it like an iterator!... kind of
Definition at line 146 of file TFRasterize.h. References TriRasterInfo< T, TT >::maxY, and TriRasterInfo< T, TT >::yPos. Referenced by TFElementBox::rasterize2D(). |
|
Definition at line 233 of file TFRasterize.h. References TriRasterInfo< T, TT >::ac, x, TriRasterInfo< T, TT >::xa, y, and TriRasterInfo< T, TT >::ya. Referenced by TriRasterInfo< T, TT >::setBary(). |
|
Definition at line 236 of file TFRasterize.h. References TriRasterInfo< T, TT >::bc, x, TriRasterInfo< T, TT >::xb, y, and TriRasterInfo< T, TT >::yb. Referenced by TriRasterInfo< T, TT >::setBary(). |
|
Definition at line 239 of file TFRasterize.h. References TriRasterInfo< T, TT >::gc, x, TriRasterInfo< T, TT >::xg, y, and TriRasterInfo< T, TT >::yg. Referenced by TriRasterInfo< T, TT >::setBary(). |
|
get the max x position in image for some scan line yp lower segment upper segment Definition at line 183 of file TFRasterize.h. References TriRasterInfo< T, TT >::_sx, gutz::clamp(), TriRasterInfo< T, TT >::ee, TriRasterInfo< T, TT >::intersectY(), TriRasterInfo< T, TT >::r, t, TriRasterInfo< T, TT >::yPos, and TriRasterInfo< T, TT >::yswapEnd. |
|
get the maximum x for the CURRENT scan line (at y())
Definition at line 177 of file TFRasterize.h. References TriRasterInfo< T, TT >::maxX. Referenced by TriRasterInfo< T, TT >::incY(), and TFElementBox::rasterize2D(). |
|
get the ending scan line (max y pos)
Definition at line 179 of file TFRasterize.h. References TriRasterInfo< T, TT >::maxY. |
|
get the min x position in image for some scanline yp
Definition at line 199 of file TFRasterize.h. References TriRasterInfo< T, TT >::_sx, gutz::clamp(), TriRasterInfo< T, TT >::intersectY(), TriRasterInfo< T, TT >::r, TriRasterInfo< T, TT >::se, t, TriRasterInfo< T, TT >::yPos, and TriRasterInfo< T, TT >::yswapStart. |
|
get the minimum x for the CURRENT scan line (at y())
Definition at line 171 of file TFRasterize.h. References TriRasterInfo< T, TT >::minX. Referenced by TriRasterInfo< T, TT >::incY(), and TFElementBox::rasterize2D(). |
|
get the starting scan line (min y pos)
Definition at line 173 of file TFRasterize.h. References TriRasterInfo< T, TT >::minY. |
|
Definition at line 138 of file TFRasterize.h. References TriRasterInfo< T, TT >::_sx. |
|
Definition at line 139 of file TFRasterize.h. References TriRasterInfo< T, TT >::_sy. |
|
Definition at line 162 of file TFRasterize.h. References TriRasterInfo< T, TT >::tri, and TriRasterInfo< T, TT >::Tri3. Referenced by TFElementBox::rasterize2D(). |
|
increment x
Definition at line 225 of file TFRasterize.h. References TriRasterInfo< T, TT >::alpha, TriRasterInfo< T, TT >::beta, TriRasterInfo< T, TT >::gamma, TriRasterInfo< T, TT >::xa, TriRasterInfo< T, TT >::xb, TriRasterInfo< T, TT >::xg, and TriRasterInfo< T, TT >::xPos. Referenced by TriRasterInfo< T, TT >::operator++(), and TFElementBox::rasterize2D(). |
|
increment y
Definition at line 215 of file TFRasterize.h. References TriRasterInfo< T, TT >::getMaxX(), TriRasterInfo< T, TT >::getMinX(), TriRasterInfo< T, TT >::maxX, TriRasterInfo< T, TT >::minX, TriRasterInfo< T, TT >::setBary(), TriRasterInfo< T, TT >::xPos, and TriRasterInfo< T, TT >::yPos. Referenced by TriRasterInfo< T, TT >::operator++(). |
|
< any type
Definition at line 287 of file TFRasterize.h. References TriRasterInfo< T, TT >::alpha, TriRasterInfo< T, TT >::beta, and TriRasterInfo< T, TT >::gamma. |
|
interpolate a 2 vector using the current barycentric coordinates
Definition at line 280 of file TFRasterize.h. References TriRasterInfo< T, TT >::alpha, TriRasterInfo< T, TT >::beta, TriRasterInfo< T, TT >::gamma, and TriRasterInfo< T, TT >::Vec3. Referenced by TFElementBox::rasterize2D(). |
|
interpolate a 3 vector using the current barycentric coordinates
Definition at line 272 of file TFRasterize.h. References TriRasterInfo< T, TT >::alpha, TriRasterInfo< T, TT >::beta, TriRasterInfo< T, TT >::gamma, and TriRasterInfo< T, TT >::Vec3. |
|
interpolate a 4 vector using the current barycentric coordinates
Definition at line 263 of file TFRasterize.h. References TriRasterInfo< T, TT >::alpha, TriRasterInfo< T, TT >::beta, TriRasterInfo< T, TT >::gamma, and TriRasterInfo< T, TT >::Vec4. |
|
Definition at line 431 of file TFRasterize.h. References gutz::ray3< T >::d, and gutz::ray3< T >::p. |
|
since gutz::intersect2D() is more general than we need for this algorithm, I optimized it by removing terms that will always be zero. And assume that we don't need to check for divide by zero r1: p = (0,yp), d=(1,0) [d1x, d1y] dot Perp([d2x,d2y]) const T div = -r.d::y; /// removed check for x/0 if(!div) return std::numeric_limits<T>::infinity(); Definition at line 417 of file TFRasterize.h. References r. Referenced by TriRasterInfo< T, TT >::getMaxX(), TriRasterInfo< T, TT >::getMinX(), and TriRasterInfo< T, TT >::setUp(). |
|
Definition at line 148 of file TFRasterize.h. References TriRasterInfo< T, TT >::incX(), TriRasterInfo< T, TT >::incY(), TriRasterInfo< T, TT >::maxX, and TriRasterInfo< T, TT >::xPos. |
|
Definition at line 167 of file TFRasterize.h. References TriRasterInfo< T, TT >::setUp(). |
|
update barycentric coordinates for the current x(),y() positions alpha, beta, gamma will be set based on x,y pos you give
Definition at line 247 of file TFRasterize.h. References TriRasterInfo< T, TT >::alpha, TriRasterInfo< T, TT >::beta, TriRasterInfo< T, TT >::gamma, TriRasterInfo< T, TT >::getAlpha(), TriRasterInfo< T, TT >::getBeta(), TriRasterInfo< T, TT >::getGamma(), x, and y. Referenced by TriRasterInfo< T, TT >::incY(), and TriRasterInfo< T, TT >::setUp(). |
|
returns true if the triangle has NO renderable pixels returns false if the has any renderable pixels
Definition at line 161 of file TFRasterize.h. References TriRasterInfo< T, TT >::setUp(), and t. Referenced by TFElementBox::rasterize2D(). |
|
setup for rasterizaton, set the triangle being rasterized NOT FOR GENERAL USE, use setTri()
2 basic cases for "tight rendering" case 1 case 2 Loose/"de-implemented" p0=sp p0=sp x---x r0 o o r0 |o | se /| r1 r1 |\ ee ||\ | p1-> o | ee se | o <- p1=mp || o| r2 \| |/ r2 ||/ | me o o me |o | p2=ep p2=ep x---x set internal triangle alias Tri* to a Tri, for easier access which of the triangle points is smallest in Y (by index) Init bounding box ( and starting point for loose ) (by integer value) need to capture this to see if we have any usefull pixels starting Y position, first scan line which case are we in for "tight" rendering case 1 start edge is horizontal end edge is horizontal case 2 precompute barycentric constants initialize them report if there are any pixels that need to be rendered build rays for tight rendering. rays always point in +y direction these correspond to case 1 above init the tmp ray, only the .p::y value will be modified... should ride the x=0 axis, point toward (1,0,0) tmpr = Ray3(Vec3(T(0.0),r[se].p::y + r[se].d::y/T(2.0),T(0.0)), Vec3(T(1.0), T(0.0), T(0.0))); now that we have edge orders figured out... set the current x position Definition at line 332 of file TFRasterize.h. References TriRasterInfo< T, TT >::_sx, TriRasterInfo< T, TT >::_sy, gutz::clamp(), TriRasterInfo< T, TT >::ee, TriRasterInfo< T, TT >::intersectY(), gutz::max3(), gutz::maxi3(), TriRasterInfo< T, TT >::maxX, TriRasterInfo< T, TT >::maxY, gutz::min3(), gutz::mini3(), TriRasterInfo< T, TT >::minX, TriRasterInfo< T, TT >::minY, r, TriRasterInfo< T, TT >::r, TriRasterInfo< T, TT >::Ray3, TriRasterInfo< T, TT >::se, TriRasterInfo< T, TT >::setBary(), TriRasterInfo< T, TT >::setupBary(), t, TriRasterInfo< T, TT >::tri, TriRasterInfo< T, TT >::Tri3, x, TriRasterInfo< T, TT >::xPos, y, TriRasterInfo< T, TT >::yPos, TriRasterInfo< T, TT >::yswapEnd, and TriRasterInfo< T, TT >::yswapStart. Referenced by TFElementBox::rasterize2D(), TriRasterInfo< T, TT >::reset(), and TriRasterInfo< T, TT >::setTri(). |
|
alpha beta gamma take care of divide alpha Definition at line 443 of file TFRasterize.h. References TriRasterInfo< T, TT >::ac, TriRasterInfo< T, TT >::bc, TriRasterInfo< T, TT >::gc, gutz::vec3< T >::x, TriRasterInfo< T, TT >::xa, TriRasterInfo< T, TT >::xb, TriRasterInfo< T, TT >::xg, gutz::vec3< T >::y, TriRasterInfo< T, TT >::ya, TriRasterInfo< T, TT >::yb, and TriRasterInfo< T, TT >::yg. Referenced by TriRasterInfo< T, TT >::setUp(). |
|
quick check if current pos (x(),y()) is inside triangle
Definition at line 254 of file TFRasterize.h. References TriRasterInfo< T, TT >::alpha, TriRasterInfo< T, TT >::beta, and TriRasterInfo< T, TT >::gamma. |
|
Definition at line 164 of file TFRasterize.h. References TriRasterInfo< T, TT >::xPos. Referenced by TFElementBox::rasterize2D(). |
|
Definition at line 165 of file TFRasterize.h. References TriRasterInfo< T, TT >::yPos. Referenced by TFElementBox::rasterize2D(). |
|
image size:
Definition at line 438 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getMaxX(), TriRasterInfo< T, TT >::getMinX(), TriRasterInfo< T, TT >::getSizeX(), TriRasterInfo< T, TT >::setUp(), and TriRasterInfo< T, TT >::TriRasterInfo(). |
|
image size:
Definition at line 438 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getSizeY(), TriRasterInfo< T, TT >::setUp(), and TriRasterInfo< T, TT >::TriRasterInfo(). |
|
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca
Definition at line 442 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getAlpha(), and TriRasterInfo< T, TT >::setupBary(). |
|
public data
Definition at line 299 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::incX(), TriRasterInfo< T, TT >::interp(), TriRasterInfo< T, TT >::interp2(), TriRasterInfo< T, TT >::interp3(), TriRasterInfo< T, TT >::interp4(), TFElementBox::rasterize2D(), TriRasterInfo< T, TT >::setBary(), and TriRasterInfo< T, TT >::validBary(). |
|
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca
Definition at line 442 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getBeta(), and TriRasterInfo< T, TT >::setupBary(). |
|
public data
Definition at line 299 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::incX(), TriRasterInfo< T, TT >::interp(), TriRasterInfo< T, TT >::interp2(), TriRasterInfo< T, TT >::interp3(), TriRasterInfo< T, TT >::interp4(), TFElementBox::rasterize2D(), TriRasterInfo< T, TT >::setBary(), and TriRasterInfo< T, TT >::validBary(). |
|
Definition at line 468 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getMaxX(), and TriRasterInfo< T, TT >::setUp(). |
|
public data
Definition at line 299 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::incX(), TriRasterInfo< T, TT >::interp(), TriRasterInfo< T, TT >::interp2(), TriRasterInfo< T, TT >::interp3(), TriRasterInfo< T, TT >::interp4(), TFElementBox::rasterize2D(), TriRasterInfo< T, TT >::setBary(), and TriRasterInfo< T, TT >::validBary(). |
|
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca
Definition at line 442 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getGamma(), and TriRasterInfo< T, TT >::setupBary(). |
|
Definition at line 306 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getMaxX(), TriRasterInfo< T, TT >::incY(), TriRasterInfo< T, TT >::operator++(), TFElementBox::rasterize2D(), and TriRasterInfo< T, TT >::setUp(). |
|
Definition at line 304 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::end(), TriRasterInfo< T, TT >::getMaxY(), TFElementBox::rasterize2D(), TriRasterInfo< T, TT >::setUp(), and TriRasterInfo< T, TT >::TriRasterInfo(). |
|
Definition at line 305 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getMinX(), TriRasterInfo< T, TT >::incY(), TFElementBox::rasterize2D(), and TriRasterInfo< T, TT >::setUp(). |
|
min/max values for setting up loops
Definition at line 303 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getMinY(), TFElementBox::rasterize2D(), and TriRasterInfo< T, TT >::setUp(). |
|
Definition at line 471 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getMaxX(), TriRasterInfo< T, TT >::getMinX(), and TriRasterInfo< T, TT >::setUp(). |
|
Definition at line 468 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getMinX(), and TriRasterInfo< T, TT >::setUp(). |
|
Definition at line 307 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getTri(), and TriRasterInfo< T, TT >::setUp(). |
|
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca
Definition at line 442 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getAlpha(), TriRasterInfo< T, TT >::incX(), and TriRasterInfo< T, TT >::setupBary(). |
|
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca
Definition at line 442 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getBeta(), TriRasterInfo< T, TT >::incX(), and TriRasterInfo< T, TT >::setupBary(). |
|
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca
Definition at line 442 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getGamma(), TriRasterInfo< T, TT >::incX(), and TriRasterInfo< T, TT >::setupBary(). |
|
Definition at line 301 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::incX(), TriRasterInfo< T, TT >::incY(), TriRasterInfo< T, TT >::operator++(), TriRasterInfo< T, TT >::setUp(), and TriRasterInfo< T, TT >::x(). |
|
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca
Definition at line 442 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getAlpha(), and TriRasterInfo< T, TT >::setupBary(). |
|
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca
Definition at line 442 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getBeta(), and TriRasterInfo< T, TT >::setupBary(). |
|
pre-computed alpha, beta, gamma constants: ex: alpha = x * xa + y * ya + ca
Definition at line 442 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getGamma(), and TriRasterInfo< T, TT >::setupBary(). |
|
Definition at line 300 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::end(), TriRasterInfo< T, TT >::getMaxX(), TriRasterInfo< T, TT >::getMinX(), TriRasterInfo< T, TT >::incY(), TriRasterInfo< T, TT >::setUp(), TriRasterInfo< T, TT >::TriRasterInfo(), and TriRasterInfo< T, TT >::y(). |
|
Definition at line 469 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getMaxX(), and TriRasterInfo< T, TT >::setUp(). |
|
Definition at line 469 of file TFRasterize.h. Referenced by TriRasterInfo< T, TT >::getMinX(), and TriRasterInfo< T, TT >::setUp(). |