vectormath2bullet.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
  3. All rights reserved.
  4. Redistribution and use in source and binary forms,
  5. with or without modification, are permitted provided that the
  6. following conditions are met:
  7. * Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. * Neither the name of the Sony Computer Entertainment Inc nor the names
  13. of its contributors may be used to endorse or promote products derived
  14. from this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  19. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef BT_AOS_VECTORMATH_BULLET_CONVERT_H
  28. #define BT_AOS_VECTORMATH_BULLET_CONVERT_H
  29. #include "PlatformDefinitions.h"
  30. #include "bullet/LinearMath/btVector3.h"
  31. #include "bullet/LinearMath/btQuaternion.h"
  32. #include "bullet/LinearMath/btMatrix3x3.h"
  33. inline Vectormath::Aos::Vector3 getVmVector3(const btVector3& bulletVec)
  34. {
  35. return Vectormath::Aos::Vector3((float)bulletVec.getX(),(float)bulletVec.getY(),(float)bulletVec.getZ());
  36. }
  37. inline btVector3 getBtVector3(const Vectormath::Aos::Vector3& vmVec)
  38. {
  39. return btVector3(vmVec.getX(),vmVec.getY(),vmVec.getZ());
  40. }
  41. inline btVector3 getBtVector3(const Vectormath::Aos::Point3& vmVec)
  42. {
  43. return btVector3(vmVec.getX(),vmVec.getY(),vmVec.getZ());
  44. }
  45. inline Vectormath::Aos::Quat getVmQuat(const btQuaternion& bulletQuat)
  46. {
  47. Vectormath::Aos::Quat vmQuat((float)bulletQuat.getX(),(float)bulletQuat.getY(),(float)bulletQuat.getZ(),(float)bulletQuat.getW());
  48. return vmQuat;
  49. }
  50. inline btQuaternion getBtQuat(const Vectormath::Aos::Quat& vmQuat)
  51. {
  52. return btQuaternion (vmQuat.getX(),vmQuat.getY(),vmQuat.getZ(),vmQuat.getW());
  53. }
  54. inline Vectormath::Aos::Matrix3 getVmMatrix3(const btMatrix3x3& btMat)
  55. {
  56. Vectormath::Aos::Matrix3 mat(
  57. getVmVector3(btMat.getColumn(0)),
  58. getVmVector3(btMat.getColumn(1)),
  59. getVmVector3(btMat.getColumn(2)));
  60. return mat;
  61. }
  62. #endif //BT_AOS_VECTORMATH_BULLET_CONVERT_H