Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

D3DXVECTOR3.xyz

Started by treeway Aug 9, 2007 at 10:24 AM 1 replies 1.1k views
Original Post
treeway
treeway
Hi In HLSL you can use the Vector2/3/4 class to access each element (e.g.Vector3.xyz or Vector3.xxx Vector3.xy) is there any way of replicating this behaviour using the D3DXVECTOR3 class. I would like to use something like D3DXVECTOR3 _3D = D3DXVECOTR3(0.5f,0.0123f,1.5f); D3DXVECTOR3 _2D = D3DXVECTOR2(_3D.xy); instead of D3DXVECTOR3 _3D = D3DXVECOTR3(0.5f,0.0123f,1.5f); D3DXVECTOR3 _2D = D3DXVECTOR2(_3D.x,_3D.y); i know its only a small change in this case but i can see it being useful. Im using C++ and DirectX 9 btw.
dave
dave
That functionality isn't built in, but you could wrap that class and add similar functionality. I don't think it is really worth it though. That kind of operation is much more commonplace in shaders.
stevenmarky
stevenmarky
I agree with Dave.

You could do it using functions, like so:
D3DXVECTOR2 yz(D3DXVECTOR3& in) {  return D3DXVECTOR2(in.y, in.z);}


I noticed you have a spelling mistake in your code 'D3DXVECOTR3' also you should not use identifiers starting with an underscore.
Quote:

You should never use names starting with an underscore for types,
variables, functions, constants or macros, as (most of) these names
have been reserved for the compiler’s internal use since ANSI C.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.