Hi guys. New here and I couldn't find a solution to my problem in older topics...
I want to take the 3 vectors describing my models (position, scale, rotation) and save them to a text file. Essentially create a map. I designate my models with integers but that is not important.
I have a struct ModelData for that: one int for model type and three D3DXVECTOR3. I pull it from all the models, create a vector and send it to my savemap method.
So I defined an insertion operator for the ModelData, and also for D3DXVECTOR3.
But I am not getting the correct output. For some reason the D3DXVECTOR3 operator is not being used. By tracing I found that it is being casted to float*.
Any ideas what I am doing wrong? Here are the code parts:
#pragma once
struct ModelData {
int type;
D3DXVECTOR3 position, size, rotation;
};
std::ostream& operator<<(std::ostream& os, const D3DXVECTOR3& vector) {
os << vector.x << 'x' << vector.y << 'x' << vector.z;
return os;
}
std::ostream& operator<<(std::ostream& os, const ModelData& data) {
os << data.type << ' ' << data.position << ' ' << data.rotation << ' ' << data.size << std::endl;
return os;
}
Like this I get what I am pretty sure is the address in HEX of data.position.x, data.rotation.x, and data.size.x as output. If I dereference data.position and so on, I get the integer part of the first float (x).