Nonstatic conversion functions; Casting different types, e.g. DirectX vector to OpenGL vector
Posted
by Markus
on Stack Overflow
See other posts from Stack Overflow
or by Markus
Published on 2010-06-08T16:57:29Z
Indexed on
2010/06/08
17:02 UTC
Read the original article
Hit count: 212
I am currently working on a game "engine" that needs to move values between a 3D engine, a physics engine and a scripting language. Since I need to apply vectors from the physics engine to 3D objects very often and want to be able to control both the 3D, as well as the physics objects through the scripting system, I need a mechanism to convert a vector of one type (e.g. vector3d<float>
) to a vector of the other type (e.g. btVector3
). Unfortunately I can make no assumptions on how the classes/structs are laid out, so a simple reinterpret_cast
probably won't do.
So the question is: Is there some sort of 'static'/non-member casting method to achieve basically this:
vector3d<float> operator vector3d<float>(btVector3 vector) {
// convert and return
}
btVector3 operator btVector3(vector3d<float> vector) {
// convert and return
}
Right now this won't compile since casting operators need to be member methods.
(error C2801: 'operator foo' must be a non-static member
)
© Stack Overflow or respective owner