XNA Vector3 to Vector3D

I use the IrrKlang sound library to create 3D sounds in the game. The problem is that the listener set is looking for a Vector3D position, but the variables that I have are in Vector3. How do I get around this?

+4
source share
1 answer

Just convert Vector3 to Vector3D, since Vector3D is just a structure with member variables X, Y, Z to represent the components x, y, z, a function like this should work fine:

public static Vector3D ToVector3D(Vector3 input) { return new Vector3D( (float)input.X, (float)input.Y, (float)input.Z ); } 

Perhaps you could implement it as a Vector3 extension (i.e. Vector3.ToVector3D ()), but in any case, converting Vector3 to Vector3D is very trivial, and the code above should help :)

+3
source

All Articles