Game Development Reference
In-Depth Information
{ return D3DXVec3Length(this); }
inline Vec3 *Normalize()
{ return static_cast<Vec3 *>(D3DXVec3Normalize(this, this)); }
inline float Dot(const Vec3 &b)
{ return D3DXVec3Dot(this, &b); }
inline Vec3 Cross(const Vec3 &b) const
{
Vec3 out;
D3DXVec3Cross(&out, this, &b);
return out;
}
Vec3(D3DXVECTOR3 &v3)
{ x = v3.x; y = v3.y; z = v3.z; }
Vec3() : D3DXVECTOR3() { }
Vec3(const float _x, const float _y, const float _z)
{ x=_x; y=_y; z=_z; }
inline Vec3(const class Vec4 &v4)
{ x = v4.x; y = v4.y; z = v4.z; }
};
class Vec4 : public D3DXVECTOR4
{
public:
inline float Length()
{ return D3DXVec4Length(this); }
inline Vec4 *Normalize()
{ return static_cast<Vec4 *>(D3DXVec4Normalize(this, this)); }
inline float Dot(const Vec4 &b)
{ return D3DXVec4Dot(this, &b); }
// If you want the cross product, use Vec3::Cross
Vec4(D3DXVECTOR4 &v4)
{ x = v4.x; y = v4.y; z = v4.z; w = v4.w; }
Vec4() : D3DXVECTOR4() { }
Vec4(const float _x, const float _y, const float _z, const float _w)
{ x=_x; y=_y; z=_z; w=_w; }
Vec4(const Vec3 &v3)
{ x = v3.x; y = v3.y; z = v3.z; w = 1.0f; }
};
typedef std::list<Vec3> Vec3List;
typedef std::list<Vec4> Vec4List;
The Vec3 and Vec4 classes wrap the DirectX D3DXVECTOR3 and D3DXVECTOR4
structures. The usefulness of the Vec3 class is pretty obvious. As for Vec4 , you
Search WWH ::




Custom Search