Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5310: Add CameraInterface to python scripting module
- Loading branch information
1 parent
b016b34
commit d8b7878
Showing
6 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#include "CameraInterface.h" | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
namespace script | ||
{ | ||
|
||
ScriptCameraView::ScriptCameraView(camera::ICameraView& cameraView) : | ||
_cameraView(cameraView) | ||
{} | ||
|
||
const Vector3& ScriptCameraView::getCameraOrigin() const | ||
{ | ||
return _cameraView.getCameraOrigin(); | ||
} | ||
|
||
void ScriptCameraView::setCameraOrigin(const Vector3& newOrigin) | ||
{ | ||
_cameraView.setCameraOrigin(newOrigin); | ||
} | ||
|
||
const Vector3& ScriptCameraView::getCameraAngles() const | ||
{ | ||
return _cameraView.getCameraAngles(); | ||
} | ||
|
||
void ScriptCameraView::setCameraAngles(const Vector3& newAngles) | ||
{ | ||
_cameraView.setCameraAngles(newAngles); | ||
} | ||
|
||
void ScriptCameraView::setOriginAndAngles(const Vector3& newOrigin, const Vector3& newAngles) | ||
{ | ||
_cameraView.setOriginAndAngles(newOrigin, newAngles); | ||
} | ||
|
||
const Vector3& ScriptCameraView::getRightVector() const | ||
{ | ||
return _cameraView.getRightVector(); | ||
} | ||
|
||
const Vector3& ScriptCameraView::getUpVector() const | ||
{ | ||
return _cameraView.getUpVector(); | ||
} | ||
|
||
const Vector3& ScriptCameraView::getForwardVector() const | ||
{ | ||
return _cameraView.getForwardVector(); | ||
} | ||
|
||
float ScriptCameraView::getFarClipPlaneDistance() const | ||
{ | ||
return _cameraView.getFarClipPlaneDistance(); | ||
} | ||
|
||
void ScriptCameraView::setFarClipPlaneDistance(float distance) | ||
{ | ||
_cameraView.setFarClipPlaneDistance(distance); | ||
} | ||
|
||
ScriptCameraView CameraInterface::getActiveView() | ||
{ | ||
return ScriptCameraView(GlobalCameraManager().getActiveView()); | ||
} | ||
|
||
void CameraInterface::registerInterface(py::module& scope, py::dict& globals) | ||
{ | ||
// Define a CameraView structure | ||
py::class_<ScriptCameraView> camera(scope, "CameraView"); | ||
camera.def(py::init<camera::ICameraView&>()); | ||
camera.def("getCameraOrigin", &ScriptCameraView::getCameraOrigin, py::return_value_policy::reference); | ||
camera.def("setCameraOrigin", &ScriptCameraView::setCameraOrigin); | ||
camera.def("getCameraAngles", &ScriptCameraView::getCameraAngles, py::return_value_policy::reference); | ||
camera.def("setCameraAngles", &ScriptCameraView::setCameraAngles); | ||
camera.def("setOriginAndAngles", &ScriptCameraView::setOriginAndAngles); | ||
camera.def("getRightVector", &ScriptCameraView::getRightVector, py::return_value_policy::reference); | ||
camera.def("getUpVector", &ScriptCameraView::getUpVector, py::return_value_policy::reference); | ||
camera.def("getForwardVector", &ScriptCameraView::getForwardVector, py::return_value_policy::reference); | ||
camera.def("getFarClipPlaneDistance", &ScriptCameraView::getFarClipPlaneDistance); | ||
camera.def("setFarClipPlaneDistance", &ScriptCameraView::setFarClipPlaneDistance); | ||
|
||
// Define the BrushCreator interface | ||
py::class_<CameraInterface> cameraManager(scope, "Camera"); | ||
cameraManager.def("getActiveView", &CameraInterface::getActiveView); | ||
|
||
// Now point the Python variable "CameraInterface" to this instance | ||
globals["GlobalCameraManager"] = this; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
|
||
#include "iscript.h" | ||
#include "icameraview.h" | ||
|
||
#include "MathInterface.h" | ||
|
||
namespace script | ||
{ | ||
|
||
class ScriptCameraView | ||
{ | ||
private: | ||
camera::ICameraView& _cameraView; | ||
|
||
public: | ||
ScriptCameraView(camera::ICameraView& cameraView); | ||
|
||
const Vector3& getCameraOrigin() const; | ||
void setCameraOrigin(const Vector3& newOrigin); | ||
|
||
const Vector3& getCameraAngles() const; | ||
void setCameraAngles(const Vector3& newAngles); | ||
|
||
void setOriginAndAngles(const Vector3& newOrigin, const Vector3& newAngles); | ||
|
||
const Vector3& getRightVector() const; | ||
const Vector3& getUpVector() const; | ||
const Vector3& getForwardVector() const; | ||
|
||
float getFarClipPlaneDistance() const; | ||
void setFarClipPlaneDistance(float distance); | ||
}; | ||
|
||
class CameraInterface : | ||
public IScriptInterface | ||
{ | ||
public: | ||
ScriptCameraView getActiveView(); | ||
|
||
// IScriptInterface implementation | ||
void registerInterface(py::module& scope, py::dict& globals) override; | ||
}; | ||
|
||
} // namespace script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters