Skip to content

Commit

Permalink
ENGINES: Add a proper convertVector2Orientation() function
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Jan 21, 2014
1 parent 5e02db4 commit e0e4662
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/engines/aurora/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
* Generic Aurora engines utility functions.
*/

#include <OgreVector2.h>
#include <OgreMath.h>

#include "common/error.h"
#include "common/stream.h"
#include "common/file.h"
Expand Down Expand Up @@ -215,4 +218,15 @@ bool dump2DA(const Common::UString &name) {
return success;
}

void convertVector2Orientation(float vX, float vY, float &radian, float &x, float &y, float &z) {
Ogre::Vector2 xAxisVector(0.0, 1.0);
Ogre::Vector2 directionVector(vX, vY);

radian = -xAxisVector.angleBetween(directionVector).valueRadians();

x = 0.0;
y = 1.0;
z = 0.0;
}

} // End of namespace Engines
2 changes: 2 additions & 0 deletions src/engines/aurora/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ bool dumpTGA(const Common::UString &name);
/** Debug method to quickly dump a 2DA to disk. */
bool dump2DA(const Common::UString &name);

void convertVector2Orientation(float vX, float vY, float &radian, float &x, float &y, float &z);

} // End of namespace Engines

#endif // ENGINES_AURORA_UTIL_H

0 comments on commit e0e4662

Please sign in to comment.