Skip to content

Commit

Permalink
pybrehappy
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate committed Jul 5, 2022
1 parent 61b446d commit ae21f50
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .tasks
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ run_environ=ZENO_LOGLEVEL=info ZENO_OPEN=/tmp/a.zsg
;run_environ=ZENO_LOGLEVEL=info ZENO_OPEN=/tmp/a.zsg ZENO_ALWAYS=1 ZENO_OPTX=1
build_dir=/tmp/zeno-build
run_target="$(VIM:build_dir)/bin/zenoedit"
build_configs=-Wno-dev -DCMAKE_INSTALL_PREFIX=/tmp/zeno-dist -DZENO_NO_WARNING:BOOL=ON -DZENO_PARALLEL_STL:BOOL=ON -DZENO_BUILD_SHARED:BOOL=ON -DZENO_MULTIPROCESS:BOOL=ON -DZENO_IPC_USE_TCP:BOOL=ON -DZENO_ENABLE_BACKWARD:BOOL=ON -DZENO_ENABLE_OPTIX:BOOL=ON -DZENO_SYSTEM_ALEMBIC:BOOL=ON -DZENO_SYSTEM_OPENVDB:BOOL=ON -DZENO_WITH_MeshSubdiv:BOOL=ON -DZENO_WITH_ZenoFX:BOOL=ON -DZENO_WITH_zenvdb:BOOL=ON -DZENO_WITH_FBX:BOOL=OFF -DZENO_WITH_SampleModel:BOOL=ON -DZENO_WITH_cgmesh:BOOL=OFF -DZENO_WITH_Rigid:BOOL=OFF -DZENO_WITH_CUDA:BOOL=OFF
build_configs=-Wno-dev -DCMAKE_INSTALL_PREFIX=/tmp/zeno-dist -DZENO_NO_WARNING:BOOL=ON -DZENO_PARALLEL_STL:BOOL=ON -DZENO_BUILD_SHARED:BOOL=ON -DZENO_MULTIPROCESS:BOOL=ON -DZENO_IPC_USE_TCP:BOOL=ON -DZENO_ENABLE_BACKWARD:BOOL=ON -DZENO_ENABLE_OPTIX:BOOL=ON -DZENO_SYSTEM_ALEMBIC:BOOL=ON -DZENO_SYSTEM_OPENVDB:BOOL=ON -DZENO_WITH_MeshSubdiv:BOOL=ON -DZENO_WITH_ZenoFX:BOOL=ON -DZENO_WITH_zenvdb:BOOL=ON -DZENO_WITH_FBX:BOOL=ON -DZENO_WITH_SampleModel:BOOL=ON -DZENO_WITH_cgmesh:BOOL=OFF -DZENO_WITH_Rigid:BOOL=OFF -DZENO_WITH_CUDA:BOOL=OFF
pre_build_cmd=(test -d build || ln -sf "$(VIM:build_dir)" build) &&
42 changes: 23 additions & 19 deletions projects/FBX/FuckMayaCamera.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
#include <zeno/zeno.h>
#include <zeno/types/CameraObject.h>
#include <zeno/utils/arrayindex.h>

namespace zeno {

struct FBXCihouCameraFov : INode {
auto m_fit_gate = array_index_safe({"Horizontal", "Vertical"},
get_input2<std::string>("fit_gate"),
"fit_gate") + 1;
auto m_focL = get_input2<float>("focL");
auto m_fw = get_input2<float>("fw");
auto m_fh = get_input2<float>("fh");
auto m_nx = get_input2<float>("nx");
auto m_ny = get_input2<float>("ny");
float c_fov = 0;
float c_aspect = m_fw/m_fh;
float u_aspect = m_ny&&m_nx? m_nx/m_ny : c_aspect;
printf("cam nx %d ny %d fw %f fh %f aspect %f %f\n", m_nx, m_ny, m_fw, m_fh, u_aspect, c_aspect);
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){
c_fov = 2.0f * std::atan(m_fw/c_aspect / (2.0f * m_focL) ) * (180.0f / M_PI);
struct CihouMayaCameraFov : INode {
virtual void apply() override {
auto m_fit_gate = array_index_safe({"Horizontal", "Vertical"},
get_input2<std::string>("fit_gate"),
"fit_gate") + 1;
auto m_focL = get_input2<float>("focL");
auto m_fw = get_input2<float>("fw");
auto m_fh = get_input2<float>("fh");
auto m_nx = get_input2<float>("nx");
auto m_ny = get_input2<float>("ny");
float c_fov = 0;
float c_aspect = m_fw/m_fh;
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);
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){
c_fov = 2.0f * std::atan(m_fw/c_aspect / (2.0f * m_focL) ) * (180.0f / M_PI);
}
set_output2("fov", c_fov);
}
set_output2("fov", c_fov);
};

ZENO_DEFNODE(FBXCihouCameraFov, {
ZENO_DEFNODE(CihouMayaCameraFov)({
{
{"float", "focL", "35"},
{"float", "nx", "0"},
Expand Down
4 changes: 2 additions & 2 deletions zenovis/src/optx/RenderEngineOptx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ struct RenderEngineOptx : RenderEngine, zeno::disable_copy {
}
}

#define MY_CAM_ID(cam) cam.m_nx, cam.m_ny, cam.m_lodup, cam.m_lodfront, cam.m_lodcenter, cam.m_fov, cam.m_fw, cam.m_fh, cam.m_focL, cam.m_fit_gate
#define MY_CAM_ID(cam) cam.m_nx, cam.m_ny, cam.m_lodup, cam.m_lodfront, cam.m_lodcenter, cam.m_fov
#define MY_SIZE_ID(cam) cam.m_nx, cam.m_ny
std::optional<decltype(std::tuple{MY_CAM_ID(std::declval<Camera>())})> oldcamid;
std::optional<decltype(std::tuple{MY_SIZE_ID(std::declval<Camera>())})> oldsizeid;
Expand Down Expand Up @@ -370,7 +370,7 @@ struct RenderEngineOptx : RenderEngine, zeno::disable_copy {
//zeno::log_warn("lodright = {}", zeno::other_to_vec<3>(lodright));
xinxinoptix::set_perspective(glm::value_ptr(lodright), glm::value_ptr(cam.m_lodup),
glm::value_ptr(cam.m_lodfront), glm::value_ptr(cam.m_lodcenter),
cam.m_fw, cam.m_fh, cam.getAspect(), cam.m_fit_gate, cam.m_fov, cam.m_focL);
cam.m_fw, cam.m_fh, cam.getAspect(), cam.m_fit_gate, cam.m_fov);
//xinxinoptix::set_projection(glm::value_ptr(cam.m_proj));
}

Expand Down
16 changes: 4 additions & 12 deletions zenovis/xinxinoptix/optixPathTracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1556,20 +1556,12 @@ void set_perspective(float const *U, float const *V, float const *W, float const

cam.eye = make_float3(E[0], E[1], E[2]);
cam.right = normalize(make_float3(U[0], U[1], U[2]));

if(fit_gate == 1){
cam.up = normalize(make_float3(V[0], V[1], V[2])) * (r_fw/u_aspect) / 2;
cam.right *= r_fw / 2;
}else if(fit_gate == 2){
cam.up = normalize(make_float3(V[0], V[1], V[2])) * (r_fh) / 2;
cam.right *= (r_fh*u_aspect) / 2;
}

cam.up = normalize(make_float3(V[0], V[1], V[2]));
cam.front = normalize(make_float3(W[0], W[1], W[2]));

if (focL > 0) {
cam.front *= focL*0.001f;
}
float radfov = fov * float(M_PI) / 180;
float tanfov = std::tan(radfov / 2.0f);
cam.front /= tanfov;

camera_changed = true;
//cam.aspect = aspect;
Expand Down

0 comments on commit ae21f50

Please sign in to comment.