XnaMath Hell, teach me how to use it

Started by
3 comments, last by Quat 14 years, 1 month ago
Im getting crazy with this.. point me to any tutorial or something... What should I use? XMFLOAT# or XMVECTOR? Is this the correct way of load simple vectors, cause it looks terrible: XMVECTOR g_liteDir[2], g_liteCor[2]; g_liteDir[0] = XMLoadFloat4( XMFLOAT4(-0.577f, 0.577f, -0.577f, 1.0f) ); g_liteDir[1] = XMLoadFloat4( XMFLOAT4(0.0f, 0.0f, -1.0f, 1.0f) ); g_liteCor[0] = XMLoadFloat4( XMFLOAT4(0.5f, 0.5f, 0.5f, 0.0f) );//gray g_liteCor[1] = XMLoadFloat4( XMFLOAT4(0.5f, 0.0f, 0.0f, 0.0f) );//red --EDIT Im sorry, actually is much worse than that, I have to create XMFLOAT variables to pass it to XMLoadFloat4...jesus, cant be true.
Advertisement
Isn't there a function called 'XMVectorSet' or something? It's been a while since I used the XM* math stuff.
Dude, yes there is!!! that is MUCH better, thanks a lot ¦)

Do you know if converting from XMVECTOR to (float*) is ok?

Like in that situation:
XMVECTOR g_liteDir[2];
ID3DX11EffectVectorVariable *g_pvLiteDirVariable;

g_pvLiteDirVariable->SetFloatVectorArray( (FLOAT*)g_liteDir, 0, 2 );
The notes on MSDN say that it would be unsafe to do that. I suspect it will work for now, but it might break if they ever update how an XMVECTOR is stored in memory.
Quote:
The notes on MSDN say that it would be unsafe to do that. I suspect it will work for now, but it might break if they ever update how an XMVECTOR is stored in memory.


How are you supposed to do it then? Manually extract x, y, z, w into a float array and set that?
-----Quat

This topic is closed to new replies.

Advertisement