cameraComponent_ScriptBinding.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. DefineEngineMethod(CameraComponent, getMode, const char*, (),,
  26. "@brief We get the first behavior of the requested type on our owner object.\n"
  27. "@return (string name) The type of the behavior we're requesting")
  28. {
  29. return "fly";
  30. }
  31. DefineEngineMethod(CameraComponent, getForwardVector, VectorF, (), ,
  32. "Get the number of static fields on the object.\n"
  33. "@return The number of static fields defined on the object.")
  34. {
  35. F32 pos = 0;
  36. MatrixF cameraMat;
  37. object->getCameraTransform(&pos, &cameraMat);
  38. VectorF returnVec = cameraMat.getForwardVector();
  39. returnVec = VectorF(mRadToDeg(returnVec.x), mRadToDeg(returnVec.y), mRadToDeg(returnVec.z));
  40. returnVec.normalize();
  41. return returnVec;
  42. }
  43. DefineEngineMethod(CameraComponent, getRightVector, VectorF, (), ,
  44. "Get the number of static fields on the object.\n"
  45. "@return The number of static fields defined on the object.")
  46. {
  47. F32 pos = 0;
  48. MatrixF cameraMat;
  49. object->getCameraTransform(&pos, &cameraMat);
  50. VectorF returnVec = cameraMat.getRightVector();
  51. returnVec = VectorF(mRadToDeg(returnVec.x), mRadToDeg(returnVec.y), mRadToDeg(returnVec.z));
  52. returnVec.normalize();
  53. return returnVec;
  54. }
  55. DefineEngineMethod(CameraComponent, getUpVector, VectorF, (), ,
  56. "Get the number of static fields on the object.\n"
  57. "@return The number of static fields defined on the object.")
  58. {
  59. F32 pos = 0;
  60. MatrixF cameraMat;
  61. object->getCameraTransform(&pos, &cameraMat);
  62. VectorF returnVec = cameraMat.getUpVector();
  63. returnVec = VectorF(mRadToDeg(returnVec.x), mRadToDeg(returnVec.y), mRadToDeg(returnVec.z));
  64. returnVec.normalize();
  65. return returnVec;
  66. }
  67. DefineEngineMethod(CameraComponent, setForwardVector, void, (VectorF newForward), (VectorF(0, 0, 0)),
  68. "Get the number of static fields on the object.\n"
  69. "@return The number of static fields defined on the object.")
  70. {
  71. object->setForwardVector(newForward);
  72. }
  73. DefineEngineMethod(CameraComponent, getWorldPosition, Point3F, (), ,
  74. "Get the number of static fields on the object.\n"
  75. "@return The number of static fields defined on the object.")
  76. {
  77. F32 pos = 0;
  78. MatrixF mat;
  79. object->getCameraTransform(&pos, &mat);
  80. return mat.getPosition();
  81. }