cameraComponent_ScriptBinding.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "console/engineAPI.h"
  23. #include "T3D/components/camera/cameracomponent.h"
  24. //Basically, this only exists for backwards compatibility for parts of the editors
  25. ConsoleMethod(CameraComponent, getMode, const char*, 2, 2, "() - We get the first behavior of the requested type on our owner object.\n"
  26. "@return (string name) The type of the behavior we're requesting")
  27. {
  28. return "fly";
  29. }
  30. DefineConsoleMethod(CameraComponent, getForwardVector, VectorF, (), ,
  31. "Get the number of static fields on the object.\n"
  32. "@return The number of static fields defined on the object.")
  33. {
  34. F32 pos = 0;
  35. MatrixF cameraMat;
  36. object->getCameraTransform(&pos, &cameraMat);
  37. VectorF returnVec = cameraMat.getForwardVector();
  38. returnVec = VectorF(mRadToDeg(returnVec.x), mRadToDeg(returnVec.y), mRadToDeg(returnVec.z));
  39. returnVec.normalize();
  40. return returnVec;
  41. }
  42. DefineConsoleMethod(CameraComponent, getRightVector, VectorF, (), ,
  43. "Get the number of static fields on the object.\n"
  44. "@return The number of static fields defined on the object.")
  45. {
  46. F32 pos = 0;
  47. MatrixF cameraMat;
  48. object->getCameraTransform(&pos, &cameraMat);
  49. VectorF returnVec = cameraMat.getRightVector();
  50. returnVec = VectorF(mRadToDeg(returnVec.x), mRadToDeg(returnVec.y), mRadToDeg(returnVec.z));
  51. returnVec.normalize();
  52. return returnVec;
  53. }
  54. DefineConsoleMethod(CameraComponent, getUpVector, VectorF, (), ,
  55. "Get the number of static fields on the object.\n"
  56. "@return The number of static fields defined on the object.")
  57. {
  58. F32 pos = 0;
  59. MatrixF cameraMat;
  60. object->getCameraTransform(&pos, &cameraMat);
  61. VectorF returnVec = cameraMat.getUpVector();
  62. returnVec = VectorF(mRadToDeg(returnVec.x), mRadToDeg(returnVec.y), mRadToDeg(returnVec.z));
  63. returnVec.normalize();
  64. return returnVec;
  65. }
  66. DefineConsoleMethod(CameraComponent, setForwardVector, void, (VectorF newForward), (VectorF(0, 0, 0)),
  67. "Get the number of static fields on the object.\n"
  68. "@return The number of static fields defined on the object.")
  69. {
  70. object->setForwardVector(newForward);
  71. }
  72. DefineConsoleMethod(CameraComponent, getWorldPosition, Point3F, (), ,
  73. "Get the number of static fields on the object.\n"
  74. "@return The number of static fields defined on the object.")
  75. {
  76. F32 pos = 0;
  77. MatrixF mat;
  78. object->getCameraTransform(&pos, &mat);
  79. return mat.getPosition();
  80. }