Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load cameras from json question #31

Closed
tigrazone opened this issue Mar 1, 2025 · 1 comment
Closed

load cameras from json question #31

tigrazone opened this issue Mar 1, 2025 · 1 comment

Comments

@tigrazone
Copy link

Hello.
I'm trying to implement import of cameras from vk_gltf_viewer(json) to my fork of RTXGI.
I have load from json to variables cameraPos, cameraTarget, cameraUp.

  auto camera = std::make_shared<PerspectiveCamera>();

How to use LookAt() and add new camera to cameras list?
I understand I can use added by me to SceneGraph.h
void AddCamera(std::shared_ptr<SceneCamera> cam) { m_Cameras.push_back(cam); }

@apanteleev , how to convert PerspectiveCamera to SceneCamera which I can change by LookAt() before add to m_Cameras?

@tigrazone
Copy link
Author

solved with this code

                        auto camera = std::make_shared<PerspectiveCamera>();
                        auto node = std::make_shared<SceneGraphNode>();
                        node->SetLeaf(camera);

                        dquat rotation;
                        double3 translation = eye_value;
                        double3 scaling = dm::double3(1.f, 1.f, 1.f);

                        decomposeAffine<double>(dm::daffine3( inverse( lookatZ( normalize(ctr_value - eye_value), normalize(up_value) ) ) ), nullptr, &rotation, nullptr);

                        node->SetTransform(&translation, &rotation, &scaling);

                        m_scene->GetSceneGraph()->Attach(m_scene->GetSceneGraph()->GetRootNode(), node);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant