-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Dacquay
committed
Mar 13, 2024
1 parent
2a41932
commit 15376dc
Showing
8 changed files
with
98 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef __VTX_APP_COMPONENT_RENDER_PROXY_CAMERA__ | ||
#define __VTX_APP_COMPONENT_RENDER_PROXY_CAMERA__ | ||
|
||
#include "app/component/render/camera.hpp" | ||
#include <memory> | ||
#include <renderer/proxy/camera.hpp> | ||
|
||
namespace VTX::App::Component::Render | ||
{ | ||
class ProxyCamera | ||
{ | ||
public: | ||
ProxyCamera(); | ||
void init(); | ||
|
||
VTX::Renderer::Proxy::Camera & getProxy() { return *_proxyPtr; } | ||
const VTX::Renderer::Proxy::Camera & getProxy() const { return *_proxyPtr; } | ||
|
||
private: | ||
void _generateProxy(); | ||
void _initCallbacks(); | ||
|
||
std::unique_ptr<VTX::Renderer::Proxy::Camera> _proxyPtr = nullptr; | ||
}; | ||
|
||
} // namespace VTX::App::Component::Render | ||
#endif |
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,54 @@ | ||
#include "app/component/render/proxy_camera.hpp" | ||
#include "app/component/scene/transform_component.hpp" | ||
#include "app/vtx_app.hpp" | ||
#include <core/chemdb/atom.hpp> | ||
#include <util/logger.hpp> | ||
#include <util/math.hpp> | ||
|
||
namespace VTX::App::Component::Render | ||
{ | ||
ProxyCamera::ProxyCamera() {} | ||
|
||
void ProxyCamera::init() | ||
{ | ||
_generateProxy(); | ||
_initCallbacks(); | ||
} | ||
|
||
void ProxyCamera::_generateProxy() | ||
{ | ||
Component::Render::Camera & cameraComp = MAIN_REGISTRY().getComponent<Component::Render::Camera>( *this ); | ||
Component::Scene::Transform & transformComp | ||
= MAIN_REGISTRY().getComponent<Component::Scene::Transform>( *this ); | ||
|
||
_proxyPtr = std::make_unique<VTX::Renderer::Proxy::Camera>( VTX::Renderer::Proxy::Camera { | ||
&cameraComp.getViewMatrix(), | ||
&cameraComp.getProjectionMatrix(), | ||
|
||
transformComp.getPosition(), | ||
VEC2I_ZERO, | ||
cameraComp.getNear(), | ||
cameraComp.getFar(), | ||
cameraComp.getProjection() == CAMERA_PROJECTION::PERSPECTIVE, | ||
} ); | ||
} | ||
void ProxyCamera::_initCallbacks() | ||
{ | ||
Component::Render::Camera & cameraComp = MAIN_REGISTRY().getComponent<Component::Render::Camera>( *this ); | ||
|
||
cameraComp.onMatrixViewChange += [ this ]( const Mat4f & p_viewMatrix ) { _proxyPtr->onMatrixView(); }; | ||
cameraComp.onMatrixProjectionChange += | ||
[ this ]( const Mat4f & p_projMatrix ) { _proxyPtr->onMatrixProjection(); }; | ||
|
||
cameraComp.onClipInfosChange += | ||
[ this ]( float p_near, float p_far ) { _proxyPtr->onCameraNearFar( p_near, p_far ); }; | ||
cameraComp.onProjectionChange += [ this ]( CAMERA_PROJECTION p_projection ) | ||
{ _proxyPtr->onPerspective( p_projection == CAMERA_PROJECTION::PERSPECTIVE ); }; | ||
|
||
// Component::Scene::Transform & transformComp | ||
// = MAIN_REGISTRY().getComponent<Component::Scene::Transform>( *this ); | ||
// transformComp.onTransformChanged += [ this ]( const Util::Math::Transform & p_transform ) | ||
//{ _proxyPtr->onCameraPosition( p_transform.getTranslationVector() ); }; | ||
} | ||
|
||
} // namespace VTX::App::Component::Render |
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
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