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

fix fbx camera #1231

Merged
merged 7 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions projects/FBX/EvalFBXAnim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "assimp/scene.h"

#include "json.hpp"

#include "Definition.h"

#include <glm/vec4.hpp>
Expand Down Expand Up @@ -448,6 +450,30 @@ struct EvalAnim{
}
};

struct EvalBlenderFile : zeno::INode {
virtual void apply() override {

}
};

ZENDEFNODE(EvalBlenderFile,
{ /* inputs: */
{
{"readpath", "script_file"},
{"readpath", "blender_file"},
{"readpath", "output_path"},
}, /* outputs: */
{
"fake"
}, /* params: */
{

}, /* category: */
{
"FBX",
}
});

struct EvalFBXAnim : zeno::INode {

virtual void apply() override {
Expand Down Expand Up @@ -481,6 +507,10 @@ struct EvalFBXAnim : zeno::INode {

if(nodeTree == nullptr || boneTree == nullptr || animInfo == nullptr){
zeno::log_error("FBX: Empty NodeTree, BoneTree or AnimInfo");
std::cout << "nodeTree == nullptr?" << (nodeTree == nullptr) << "\n";
std::cout << "boneTree == nullptr?" << (boneTree == nullptr) << "\n";
std::cout << "animInfo == nullptr?" << (animInfo == nullptr) << "\n";
throw zeno::makeError("Empty FBX Data");
}

auto prim = std::make_shared<zeno::PrimitiveObject>();
Expand Down
4 changes: 4 additions & 0 deletions projects/FBX/ExtractFBXData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ struct ExtractCameraData : zeno::INode {
virtual void apply() override {
auto icam = get_input<ICamera>("camobject");
auto key = get_input<zeno::StringObject>("key")->get();
if(icam->value.find(key) == icam->value.end()){
throw zeno::makeError("Camera Not Found");
}

auto cam = icam->value.at(key);

auto pos = std::make_shared<zeno::NumericObject>();
Expand Down
3 changes: 3 additions & 0 deletions projects/FBX/MayaCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ struct CihouMayaCameraFov : INode {
float u_aspect = m_ny&&m_nx? m_nx/m_ny : c_aspect;
zeno::log_info("cam nx {} ny {} fw {} fh {} aspect {} {}",
m_nx, m_ny, m_fw, m_fh, u_aspect, c_aspect);
std::cout << "m_fit_gate:" << m_fit_gate << "\n";
std::cout << "u_aspect:" << u_aspect << "\n";
std::cout << "c_aspect:" << c_aspect << "\n";
if(m_fit_gate == 1){
c_fov = 2.0f * std::atan(m_fh/(u_aspect/c_aspect) / (2.0f * m_focL) ) * (180.0f / M_PI);
}else if(m_fit_gate == 2){
Expand Down
3 changes: 3 additions & 0 deletions projects/FBX/ReadFBX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ struct Mesh{
cam->GetCameraMatrix(camMatrix);

SCamera sCam;
sCam.focL = cam->mFocalLength;
sCam.filmW = cam->mFilmWidth * 25.4f; // inch to mm
sCam.filmH = cam->mFilmHeight * 25.4f;
std::cout << "Camera Name: " << camName << "\n";
fbxData.iCamera.value[camName] = sCam;

Expand Down
255 changes: 255 additions & 0 deletions projects/FBX/scripts/blender.py

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions projects/FBX/scripts/dbuild.bat

This file was deleted.

4 changes: 4 additions & 0 deletions projects/USD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ if(DEFINED ZENO_USD_DEV_ROOT)
message(STATUS "Dev Root ${ZENO_USD_DEV_ROOT} Get ${DEV_SOURCE}")
target_include_directories(zeno PRIVATE ${ZENO_USD_DEV_ROOT})
target_sources(zeno PRIVATE ${DEV_SOURCE})
else()
file(GLOB DEV_SOURCE ${CMAKE_CURRENT_LIST_DIR}/dev/*.cpp ${CMAKE_CURRENT_LIST_DIR}/dev/*.h)
target_include_directories(zeno PRIVATE ${CMAKE_CURRENT_LIST_DIR}/dev)
target_sources(zeno PRIVATE ${DEV_SOURCE})
endif()

if(DEFINED ZENO_USD_ROOT)
Expand Down
Loading
Loading