Jump to content
  • Advertisement
Sign in to follow this  
thedodgeruk

initilise a D3DXVECTOR

This topic is 3080 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


.h file
D3DXVECTOR3 rotWorld;


.cpp file
rotWorld.x = 0;
rotWorld.y = 0;
rotWorld.z = 0;




is there a simple way to set all componants of D3DXVECTOR to zero

Share this post


Link to post
Share on other sites
Advertisement
My vector class' contain static member variables called 'Zero' so I can copy construct/assign 0 to all components of the vector (without having to create a temporary). Could also pass it to a function if you really wanted, meh.

You can define a constant such as the following:
const D3DXVECTOR3 D3DXZeroVec3(0, 0, 0);

// ... and then maybe ...

D3DXVECTOR3 rotWorld = D3DXZeroVec3;

// .. but whats wrong with just ...

D3DXVECTOR3 rotWorld(0.0f, 0.0f, 0.0f); // constructor ?







maybe that would help, I donno..

PS: This method comes in particularly handy for matrices IMO, in this way you can define the special 'Identity' and 'Zero' matrices and. Looks nicer than a function call, virtually the only difference.

Share this post


Link to post
Share on other sites
when initilizing variables inside of a class you should use an initilizer list attached to the constructer


MyClass::MyClass() : randomD3DVec(0.0f,0.0f,0.0f), randomInt(0), randomFloat(0.0f)
{

}



This is the appropriate way to do it. It has to do with variables in a class being created earlier than some other class construction, so its better to specify them to be initilized on their creation rather than creating them then assigning values to them.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!