| 1 |
#include "CameraInterface.h" |
| 2 |
|
| 3 |
#include "math/Vector3.h" |
| 4 |
#include <pybind11/pybind11.h> |
| 5 |
|
| 6 |
namespace script |
| 7 |
{ |
| 8 |
|
| 9 |
ScriptCameraView::ScriptCameraView(camera::ICameraView& cameraView) : |
| 10 |
_cameraView(cameraView) |
| 11 |
{} |
| 12 |
|
| 13 |
const Vector3& ScriptCameraView::getCameraOrigin() const |
| 14 |
{ |
| 15 |
return _cameraView.getCameraOrigin(); |
| 16 |
} |
| 17 |
|
| 18 |
void ScriptCameraView::setCameraOrigin(const Vector3& newOrigin) |
| 19 |
{ |
| 20 |
_cameraView.setCameraOrigin(newOrigin); |
| 21 |
} |
| 22 |
|
| 23 |
const Vector3& ScriptCameraView::getCameraAngles() const |
| 24 |
{ |
| 25 |
return _cameraView.getCameraAngles(); |
| 26 |
} |
| 27 |
|
| 28 |
void ScriptCameraView::setCameraAngles(const Vector3& newAngles) |
| 29 |
{ |
| 30 |
_cameraView.setCameraAngles(newAngles); |
| 31 |
} |
| 32 |
|
| 33 |
void ScriptCameraView::setOriginAndAngles(const Vector3& newOrigin, const Vector3& newAngles) |
| 34 |
{ |
| 35 |
_cameraView.setOriginAndAngles(newOrigin, newAngles); |
| 36 |
} |
| 37 |
|
| 38 |
const Vector3& ScriptCameraView::getRightVector() const |
| 39 |
{ |
| 40 |
return _cameraView.getRightVector(); |
| 41 |
} |
| 42 |
|
| 43 |
const Vector3& ScriptCameraView::getUpVector() const |
| 44 |
{ |
| 45 |
return _cameraView.getUpVector(); |
| 46 |
} |
| 47 |
|
| 48 |
const Vector3& ScriptCameraView::getForwardVector() const |
| 49 |
{ |
| 50 |
return _cameraView.getForwardVector(); |
| 51 |
} |
| 52 |
|
| 53 |
float ScriptCameraView::getFarClipPlaneDistance() const |
| 54 |
{ |
| 55 |
return _cameraView.getFarClipPlaneDistance(); |
| 56 |
} |
| 57 |
|
| 58 |
void ScriptCameraView::setFarClipPlaneDistance(float distance) |
| 59 |
{ |
| 60 |
_cameraView.setFarClipPlaneDistance(distance); |
| 61 |
} |
| 62 |
|
| 63 |
void ScriptCameraView::refresh() |
| 64 |
{ |
| 65 |
_cameraView.queueDraw(); |
| 66 |
} |
| 67 |
|
| 68 |
ScriptCameraView CameraInterface::getActiveView() |
| 69 |
{ |
| 70 |
return ScriptCameraView(GlobalCameraManager().getActiveView()); |
| 71 |
} |
| 72 |
|
| 73 |
void CameraInterface::registerInterface(py::module& scope, py::dict& globals) |
| 74 |
{ |
| 75 |
// Define a CameraView structure |
| 76 |
py::class_<ScriptCameraView> camera(scope, "CameraView"); |
| 77 |
camera.def(py::init<camera::ICameraView&>()); |
| 78 |
camera.def("getCameraOrigin", &ScriptCameraView::getCameraOrigin, py::return_value_policy::reference); |
| 79 |
camera.def("setCameraOrigin", &ScriptCameraView::setCameraOrigin); |
| 80 |
camera.def("getCameraAngles", &ScriptCameraView::getCameraAngles, py::return_value_policy::reference); |
| 81 |
camera.def("setCameraAngles", &ScriptCameraView::setCameraAngles); |
| 82 |
camera.def("setOriginAndAngles", &ScriptCameraView::setOriginAndAngles); |
| 83 |
camera.def("getRightVector", &ScriptCameraView::getRightVector, py::return_value_policy::reference); |
| 84 |
camera.def("getUpVector", &ScriptCameraView::getUpVector, py::return_value_policy::reference); |
| 85 |
camera.def("getForwardVector", &ScriptCameraView::getForwardVector, py::return_value_policy::reference); |
| 86 |
camera.def("getFarClipPlaneDistance", &ScriptCameraView::getFarClipPlaneDistance); |
| 87 |
camera.def("setFarClipPlaneDistance", &ScriptCameraView::setFarClipPlaneDistance); |
| 88 |
camera.def("refresh", &ScriptCameraView::refresh); |
| 89 |
|
| 90 |
// Define the BrushCreator interface |
| 91 |
py::class_<CameraInterface> cameraManager(scope, "Camera"); |
| 92 |
cameraManager.def("getActiveView", &CameraInterface::getActiveView); |
| 93 |
|
| 94 |
// Now point the Python variable "GlobalCameraManager" to this instance |
| 95 |
globals["GlobalCameraManager"] = this; |
| 96 |
} |
| 97 |
|
| 98 |
} |