Calling a D3DXVECTOR3

i currently have this code for using the D3DXVECTOR3 to do some math,

D3DXVECTOR3 TargetVector(D3DXVECTOR3 *target, D3DXVECTOR3 *firer)
{
D3DXVECTOR3 *Out;
D3DXVECTOR3 v;

v.x = target->y * firer->z - target->z * firer->y;
v.y = target->z * firer->x - target->x * firer->z;
v.z = target->x * firer->y - target->y * firer->x;

*Out = v;
return v;
}

how would i call it from lets say cout?
There shall be defined

std::ostream & operator <<( std::ostream &, const D3DXVECTOR3 & );

in your program.
ah thanks, is there anything i need to declare?
Histerial wrote:
ah thanks, is there anything i need to declare?
vlad from moscow wrote:
There shall be defined

std::ostream & operator <<( std::ostream &, const D3DXVECTOR3 & );

in your program.


It should be something like:

1
2
3
4
std::ostream & operator <<( std::ostream & out, const D3DXVECTOR3 & vec)
{
      out << "[" << vec.x << ", " << vec.y << ", " << vec.z << "]";
}


After this you can:

1
2
3
D3DXVECTOR3 vector;
// Do math
cout << vector;


Given x = 0, y = 1, z = 2, it will print out like:
[0.0, 1.0, 2.0]
Last edited on
Ah Thanks :)
Topic archived. No new replies allowed.