CameraSceneNode.ixx File
Camera scene node adapter providing view and projection matrices within a scene graph. More...
Included Headers
#include <cassert>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <helios.scene.SceneNode>
#include <helios.scene.Camera>
#include <helios.math.TransformType>
#include <helios.math.types>
Namespaces Index
| namespace | helios |
| namespace | scene |
Classes Index
| class | CameraSceneNode |
|
Represents an adapter for cameras, allowing spatial positioning and transformation within the scene graph. More... | |
Description
Camera scene node adapter providing view and projection matrices within a scene graph.
File Listing
The file content with the documentation metadata removed is:
19export namespace helios::scene {
22 * @brief Represents an adapter for cameras, allowing spatial positioning and transformation within the scene graph.
31 class CameraSceneNode : public SceneNode {
52 explicit CameraSceneNode(std::unique_ptr<helios::scene::Camera> camera) :
54 if (!camera_) {
81 [[nodiscard]] const helios::scene::Camera& camera() const noexcept {
82 return *camera_;
90 [[nodiscard]] helios::scene::Camera& camera() noexcept {
91 return *camera_;
112 void lookAt(helios::math::vec3f target, helios::math::vec3f up) {
114 const auto wt = worldTransform();
115 const auto worldPos = helios::math::vec3f(
120 auto y = up.normalize();
121 auto x = helios::math::cross(y, z).normalize();
122 y = helios::math::cross(z, x).normalize();
124 const helios::math::mat4f worldRotation = helios::math::mat4f{
131 if (!helios::math::transformTypeMatch(
136 setRotation(worldRotation);
141 assert(parent() && "parent() of CameraSceneNode returned null, are you sure the node was added properly to the scenegraph?");
142 const helios::math::mat4f pT = parent()->cachedWorldTransform();
144 const helios::math::mat4f parentRotInv = pT.decompose(helios::math::TransformType::Rotation).transpose();
147 setRotation(parentRotInv * worldRotation);
162 void lookAtLocal(helios::math::vec3f targetLocal, helios::math::vec3f upLocal) {
164 const auto lt = localTransform().transform();
165 const auto localPos = helios::math::vec3f(
170 auto y = upLocal.normalize();
171 auto x = helios::math::cross(y, z).normalize();
172 y = helios::math::cross(z, x).normalize();
174 const helios::math::mat4f localRotation = helios::math::mat4f{
181 setRotation(localRotation);
193 void onWorldTransformUpdate() noexcept override {
198 const auto wt = helios::scene::SceneNode::cachedWorldTransform();
200 const auto x = helios::math::vec3f{wt(0, 0), wt(1, 0), wt(2, 0)};
201 const auto y = helios::math::vec3f{wt(0, 1), wt(1, 1), wt(2, 1)};
202 const auto z = helios::math::vec3f{wt(0, 2), wt(1, 2), wt(2, 2)};
204 const auto eye = helios::math::vec3f{wt(0, 3), wt(1, 3), wt(2, 3)};
207 auto inv = helios::math::mat4f{
214 camera_->setViewMatrix(inv);
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.