// (c) Tuomas J. Lukka #ifndef VOB_LOD_TEXPOLY_HXX #define VOB_LOD_TEXPOLY_HXX #include namespace Vob { namespace LOD { /** A class that allows accumulation of * estimated LODs of textured polys. * Used to estimate what mipmap level of texture would * be required. */ struct TexAccum { TexAccum(); enum { NLEVELS = 20 }; /** The number of pixels estimated to have been rendered * at each level of detail. * Level 0 : texture coordinates (0,1)x(0,1) == 1 pixel, * Level 1 : texture coordinates (0,.5)x(0,.5) == 1 pixel, ... */ double pixels[NLEVELS]; /** Add a triangle. * Currently, this will calculate a rough estimate * of the LOD, assuming isotropic transformations, * by calculating the ratio of the areas; a more accurate * algorithm may be substituted later. * @param p1,p2,p3 The corners in screen space, in pixel coords * @param t1,t2,t3 The corners in texture coordinate space. */ void add(ZPt &p1, ZPt &p2, ZPt &p3, Pt &t1, Pt &t2, Pt &t3); void clear(); }; } } #endif