Building a flexiable renderer
typedef union _Vector2f
{ struct { float x, y; }; struct { float u, v; }; float arr[2]; FORCEINLINE void init() { x = y = 0.0f; } FORCEINLINE void init( float _x, float _y ) { x = _x; y = _y; }}
Vector2f;typedef union _Vector3f
{ struct { float x, y, z; }; struct { float r, g, b; }; float arr[3]; FORCEINLINE void init() { x = y = z = 0.0f; } FORCEINLINE void init( float _x, float _y, float _z ) { x = _x; y = _y; z = _z; }}
Vector3f;typedef union _Vector4f
{ struct { float x, y, z, w; }; struct { float r, g, b, a; }; struct { Vector3f abc; float d; }; struct { Vector2f uv; float du, dv; }; float arr[4]; __m128 mm; FORCEINLINE void init() { x = y = z = 0.0f; w = 1.0f; } FORCEINLINE void init( float _x, float _y, float _z ) { x = _x; y = _y; z = _z; w = 1.0f; } FORCEINLINE void init( float _x, float _y, float _z, float _w ) { x = _x; y = _y; z = _z; w = _w; }}
Vector4f;typedef union _Vector2i
{ struct { int x, y; }; int arr[2];}
Vector2i;typedef union _Vector3i
{ struct { int x, y, z; }; struct { int r, g, b; }; int arr[3];}
Vector3i;typedef union _Vector4i
{ struct { int x, y, z, w; }; struct { int r, g, b, a; }; int arr[4];}
Vector4i;typedef union _Vector2b
{ struct { BYTE x, y; }; BYTE arr[2];}
Vector2b;typedef union _Vector3b
{ struct { BYTE x, y, z; }; struct { BYTE r, g, b; }; BYTE arr[3];}
Vector3b;typedef union _Vector4b
{ struct { BYTE x, y, z, w; }; struct { BYTE r, g, b, a; }; BYTE arr[4];}
Vector4b;typedef union _Matrix33f
{ struct { float m1, m2, m3, m4, m5, m6, m7, m8, m9; }; float arr[9]; float m[3][3];}
Matrix33f;typedef union _Matrix44f
{ struct { float m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16; }; struct { float rs[12]; Vector4f translation; }; float arr[16]; float m[4][4]; __m128 mm[4]; Vector4f v[4];}
Matrix44f;typedef union _Rect4i
{ struct { int left, right, top, bottom; }; int arr[4];}
Rect4i;typedef union _Rect6i
{ struct { int left, right, top, bottom, width, height; }; int arr[6];}
Rect6i;typedef union _Rect4f
{ struct { float xmin, xmax, ymin, ymax; }; float arr[4];}
Rect4f;typedef union _Rect6f
{ struct { float xmin, xmax, ymin, ymax, width, height; }; float arr[6];}
Rect6f;typedef union _Range2f
{ struct { float min, max; }; float arr[2]; FORCEINLINE bool cover( float _s ) const { if( _s >= min && _s <= max ) return true; else return false; }}
Range2f;typedef union _Bound6f
{ struct { float xmin, xmax, ymin, ymax, zmin, zmax; }; struct { Range2f xrange, yrange, zrange; }; Range2f range[3]; float arr[6]; FORCEINLINE void operator += ( const _Bound6f & b ) { if( xmin > b.xmin ) xmin = b.xmin; if( xmax < b.xmax ) xmax = b.xmax; if( ymin > b.ymin ) ymin = b.ymin; if( ymax < b.ymax ) ymax = b.ymax; if( zmin > b.zmin ) zmin = b.zmin; if( zmax < b.zmax ) zmax = b.zmax; } FORCEINLINE void operator += ( const Vector3f & v ) { if( xmin > v.x ) xmin = v.x; if( xmax < v.x ) xmax = v.x; if( ymin > v.y ) ymin = v.y; if( ymax < v.y ) ymax = v.y; if( zmin > v.z ) zmin = v.z; if( zmax < v.z ) zmax = v.z; } FORCEINLINE void operator = ( const Vector3f & v ) { xmax = xmin = v.x; ymax = ymin = v.y; zmax = zmin = v.z; }}
Bound6f;typedef union _Bound9f
{ struct { float xmin, xmax, ymin, ymax, zmin, zmax, width, height, length; }; struct { Bound6f box; float width, height, length; }; float arr[9]; FORCEINLINE void normalize() { width = xmax - xmin; height = ymax - ymin; length = zmax - zmin; }}
Bound9f;
posted on
2007-02-25 12:38
Len3d 阅读(
...) 评论(
)
编辑
收藏
转载于:https://www.cnblogs.com/len3d/archive/2007/02/25/655844.html
相关资源:数据结构—成绩单生成器