Sign in to follow this  
Icebone1000

XnaMath Hell, teach me how to use it

Recommended Posts

Icebone1000    1958
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.

Share this post


Link to post
Share on other sites
Icebone1000    1958
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 );

Share this post


Link to post
Share on other sites
Nypyren    12065
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.

Share this post


Link to post
Share on other sites
Quat    568
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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this