Jump to content
  • Advertisement
Sign in to follow this  
Icebone1000

XnaMath Hell, teach me how to use it

This topic is 2997 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
Isn't there a function called 'XMVectorSet' or something? It's been a while since I used the XM* math stuff.

Share this post


Link to post
Share on other sites
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!