diff --git a/engine/core/component/Transform.h b/engine/core/component/Transform.h index cd5b1f1b..dfb1b669 100644 --- a/engine/core/component/Transform.h +++ b/engine/core/component/Transform.h @@ -25,6 +25,8 @@ namespace Supernova{ Matrix4 modelMatrix; Matrix4 normalMatrix; + + // internal use only, it depends of camera (same scene can have multiple cameras) Matrix4 modelViewProjectionMatrix; bool staticObject = false; diff --git a/engine/core/object/Camera.cpp b/engine/core/object/Camera.cpp index dad75125..64e5e200 100644 --- a/engine/core/object/Camera.cpp +++ b/engine/core/object/Camera.cpp @@ -311,6 +311,21 @@ Vector3 Camera::getWorldRight() const{ return camera.worldRight; } +Matrix4 Camera::getViewMatrix() const{ + CameraComponent& camera = getComponent(); + return camera.viewMatrix; +} + +Matrix4 Camera::getProjectionMatrix() const{ + CameraComponent& camera = getComponent(); + return camera.projectionMatrix; +} + +Matrix4 Camera::getViewProjectionMatrix() const{ + CameraComponent& camera = getComponent(); + return camera.viewProjectionMatrix; +} + void Camera::rotateView(float angle){ if (angle != 0){ CameraComponent& camera = getComponent(); diff --git a/engine/core/object/Camera.h b/engine/core/object/Camera.h index 972207a6..068df039 100644 --- a/engine/core/object/Camera.h +++ b/engine/core/object/Camera.h @@ -70,6 +70,10 @@ namespace Supernova{ Vector3 getWorldUp() const; Vector3 getWorldRight() const; + Matrix4 getViewMatrix() const; + Matrix4 getProjectionMatrix() const; + Matrix4 getViewProjectionMatrix() const; + void rotateView(float angle); void rotatePosition(float angle); diff --git a/engine/core/object/Object.cpp b/engine/core/object/Object.cpp index a64a12fb..92d100f5 100644 --- a/engine/core/object/Object.cpp +++ b/engine/core/object/Object.cpp @@ -197,11 +197,6 @@ Matrix4 Object::getNormalMatrix() const{ return transform.normalMatrix; } -Matrix4 Object::getModelViewProjectionMatrix() const{ - Transform& transform = getComponent(); - return transform.modelViewProjectionMatrix; -} - void Object::addChild(Object* child){ scene->addEntityChild(this->entity, child->entity, false); } diff --git a/engine/core/object/Object.h b/engine/core/object/Object.h index 0e838326..c3d5567b 100644 --- a/engine/core/object/Object.h +++ b/engine/core/object/Object.h @@ -65,7 +65,6 @@ namespace Supernova{ Matrix4 getModelMatrix() const; Matrix4 getNormalMatrix() const; - Matrix4 getModelViewProjectionMatrix() const; void updateTransform(); diff --git a/engine/core/script/binding/ObjectClassesLua.cpp b/engine/core/script/binding/ObjectClassesLua.cpp index c06f4461..802efd5d 100644 --- a/engine/core/script/binding/ObjectClassesLua.cpp +++ b/engine/core/script/binding/ObjectClassesLua.cpp @@ -201,7 +201,6 @@ void LuaBinding::registerObjectClasses(lua_State *L){ .addProperty("localMatrix", &Object::getLocalMatrix, &Object::setLocalMatrix) .addProperty("modelMatrix", &Object::getModelMatrix) .addProperty("normalMatrix", &Object::getNormalMatrix) - .addProperty("modelViewProjectionMatrix", &Object::getModelViewProjectionMatrix) .addFunction("updateTransform", &Object::updateTransform) .addFunction("getBody2D", &Object::getBody2D) .addFunction("removeBody2D", &Object::removeBody2D) @@ -237,6 +236,9 @@ void LuaBinding::registerObjectClasses(lua_State *L){ .addFunction("getWorldDirection", &Camera::getWorldDirection) .addFunction("getWorldUp", &Camera::getWorldUp) .addFunction("getWorldRight", &Camera::getWorldRight) + .addFunction("getViewMatrix", &Camera::getViewMatrix) + .addFunction("getProjectionMatrix", &Camera::getProjectionMatrix) + .addFunction("getViewProjectionMatrix", &Camera::getViewProjectionMatrix) .addFunction("rotateView", &Camera::rotateView) .addFunction("rotatePosition", &Camera::rotatePosition) .addFunction("elevateView", &Camera::elevateView)