UV.h

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @class  UV
00003    @author Travis Fischer (fisch0920@gmail.com)
00004    @date   Spring 2008
00005    
00006    @brief
00007       UV coordinate wrapper for texture coordinates
00008    
00009    @note u and v should lie in [0, 1]
00010    <!-------------------------------------------------------------------->**/
00011 
00012 #ifndef UV_H_
00013 #define UV_H_
00014 
00015 #include <common/math/algebra.h>
00016 
00017 struct UV {
00018    union {
00019       struct {
00020          real_t u;
00021          real_t v;
00022       };
00023       
00024       real_t data[2];
00025    };
00026    
00027    inline UV(real_t u_, real_t v_)
00028       : u(u_), v(v_)
00029    { }
00030    
00031    inline UV(const Point2 &p)
00032       : u(p[0]), v(p[1])
00033    { }
00034    
00035    inline UV() 
00036       : u(0), v(0)
00037    { }
00038    
00039    inline real_t operator[](unsigned index) const {
00040       ASSERT(index >= 0 && index <= 1);
00041       
00042       return data[index];
00043    }
00044    
00045    inline real_t &operator[](unsigned index) {
00046       ASSERT(index >= 0 && index <= 1);
00047       
00048       return data[index];
00049    }
00050 };
00051 
00052 #endif // UV_H_
00053 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6