Date: Tue, 17 Dec 2024 00:58:54 GMT From: Robert Clausecker <fuz@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: 9f3642523e98 - main - graphics/zeno: enabled more features Message-ID: <202412170058.4BH0wsDx094632@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by fuz: URL: https://cgit.FreeBSD.org/ports/commit/?id=9f3642523e98ddbebc4a2a30c72f3f9b0b6e3cfc commit 9f3642523e98ddbebc4a2a30c72f3f9b0b6e3cfc Author: Martin Filla <freebsd@sysctl.cz> AuthorDate: 2024-12-01 08:02:19 +0000 Commit: Robert Clausecker <fuz@FreeBSD.org> CommitDate: 2024-12-17 00:31:50 +0000 graphics/zeno: enabled more features PR: 283061 --- graphics/zeno/Makefile | 89 +++- graphics/zeno/distinfo | 14 +- graphics/zeno/files/patch-ui_zenoui_CMakeLists.txt | 26 ++ .../files/patch-zeno_src_nodes_zeno__animation.cpp | 480 +++++++++++++++++++++ 4 files changed, 595 insertions(+), 14 deletions(-) diff --git a/graphics/zeno/Makefile b/graphics/zeno/Makefile index acf4baa103c3..c97685faa411 100644 --- a/graphics/zeno/Makefile +++ b/graphics/zeno/Makefile @@ -1,5 +1,6 @@ PORTNAME= zeno DISTVERSION= 2024.10.1 +PORTREVISION= 1 CATEGORIES= graphics MAINTAINER= freebsd@sysctl.cz @@ -9,35 +10,97 @@ WWW= https://zenustech.com/ LICENSE= MPL20 LICENSE_FILE= ${WRKSRC}/LICENSE -BUILD_DEPENDS= openmpi>0:net/openmpi \ +BUILD_DEPENDS= alembic>0:graphics/alembic \ + boost-libs>=1.85.0:devel/boost-libs \ + c-blosc2>0:archivers/c-blosc2 \ + openmpi>0:net/openmpi \ cgal>=5.0.2:math/cgal \ onetbb>0:devel/onetbb \ - openvdb>0:misc/openvdb -LIB_DEPENDS= libcryptopp.so:security/cryptopp + opencv>0:graphics/opencv \ + sdl2>0:devel/sdl20 \ + qwt6-qt5>0:x11-toolkits/qwt6 -USES= cmake compiler:c++17-lang eigen:3 localbase:ldflags qt:5 -USE_GITHUB= yes -USE_GCC= yes -GH_ACCOUNT= zenustech +LIB_DEPENDS= libAlembic.so:graphics/alembic \ + libcryptopp.so:security/cryptopp \ + libImath-3_1.so:math/Imath \ + libtiff.so:graphics/tiff \ + libopencv_highgui.so:graphics/opencv \ + libopencv_stitching.so:graphics/opencv \ + libopencv_videoio.so:graphics/opencv \ + libopencv_imgcodecs.so:graphics/opencv \ + libopencv_xfeatures2d.so:graphics/opencv \ + libopencv_ml.so:graphics/opencv \ + libopencv_shape.so:graphics/opencv \ + libopencv_calib3d.so:graphics/opencv \ + libopencv_features2d.so:graphics/opencv \ + libopencv_imgproc.so:graphics/opencv \ + libopencv_flann.so:graphics/opencv \ + libopencv_core.so:graphics/opencv + +USES= cmake compiler:c++17-lang eigen:3 localbase:ldflags pkgconfig qt:5 USE_LDCONFIG= yes USE_QT= core gui network opengl svg widgets buildtools:build qmake:build +USE_GCC= yes +USE_SDL= sdl2 +USE_XORG= xext + +USE_GITHUB= yes +GH_ACCOUNT= zenustech +GH_TUPLE+= zenustech:openvdb:74a95a74d91e0115be00d7b94391f5607e02d60f:openvdb/projects/zenvdb/openvdb \ + zenustech:assimp:745fcc9ba0c79feb4edfc71f464d6d4c920ecc06:assimp/projects/FBX/assimp \ + zenustech:dem-bones-bin:30a39493f0394dfedc5d72ea463405b8f07a446e:dem/projects/FBX/dem-bones-bin \ + zenustech:libigl:9af4b833cb37c0d4b77ca62b7502284b3a83a47e:libigl/projects/cgmesh/libigl \ + zenustech:bullet3:aa4931408428cd72057e59627770fc027c5bb0be:bullet/projects/Rigid/bullet3 \ + zenustech:OpenSubdiv:a50680658f9732a41fea8e150310cfb9b147dc3c:opensubdiv/projects/MeshSubdiv/OpenSubdiv CMAKE_ON= ZENO_BUILD_EDITOR ZENO_BUILD_SHARED ZENO_IPC_USE_TCP \ - ZENO_MULTIPROCESS ZENO_NO_WARNING ZENO_USE_CCACHE + ZENO_MULTIPROCESS ZENO_NO_WARNING ZENO_USE_CCACHE \ + ZENOFX_ENABLE_LBVH \ + ZENO_WITH_Rigid \ + ZENO_WITH_oldzenbase \ + ZENO_WITH_TreeSketch \ + ZENO_SYSTEM_OPENVDB \ + ZENO_WITH_Functional \ + ZENO_WITH_LSystem \ + ZENO_WITH_mesher \ + ZENO_WITH_CalcGeometryUV \ + ZENO_WITH_MeshSubdiv \ + ZENO_WITH_Audio \ + ZENO_WITH_PBD \ + ZENO_WITH_GUI \ + ZENO_WITH_ImgCV \ + ZENO_WITH_TOOL_FLIPtools \ + ZENO_WITH_TOOL_cgmeshTools \ + ZENO_WITH_TOOL_BulletTools \ + ZENO_WITH_TOOL_HerculesTools + CMAKE_OFF= ZENO_BUILD_DESIGNER ZENO_BUILD_PLAYER ZENO_INSTALL_TARGET \ ZENO_MARCH_NATIVE ZENO_OPTIX_PROC ZENO_USE_FAST_MATH \ - ZENO_WIN32_RC ZENO_WITH_CUDA + ZENO_WIN32_RC ZENO_WITH_CUDA \ + ZENO_WITH_ZenoFX ZENOFX_ENABLE_OPENVDB \ + ZENO_WITH_Alembic ZENO_SYSTEM_ALEMBIC + #ZENO_WITH_FastFLIP ZENO_WITH_zenvdb # compile zenovdb + #ZENO_WITH_Euler ZENO_WITH_zenvdb # compile zenvdb killed gcc + #ZENO_WITH_Skinning ZENO_WITH_cgmesh # git download project dependent skinning on cgmesh + #ZENO_WITH_cgmesh ZENO_WITH_FEM # git download projects dependent cgmesh on FEM + #ZENO_WITH_DemBones ZENO_WITH_FBX # harcoded folder and libs in CMakefile + #ZENO_WITH_SampleModel # error: '_pgmptr' was not declared in this scope + # ZENO_BUILD_DESIGNER - bug https://github.com/zenustech/zeno/issues/1907 -# fix on 13.3: "ld: error: undefined reference due to --no-allow-shlib-undefined: +# fix on 14.1: "ld: error: undefined reference due to --no-allow-shlib-undefined: LDFLAGS+= -Wl,--allow-shlib-undefined -lomp PLIST_FILES= bin/autotest \ bin/zenoedit \ lib/libzeno.so + +pre-configure: + ${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' ${WRKSRC}/ui/zenoui/CMakeLists.txt + do-install: - ${INSTALL_PROGRAM} ${WRKDIR}/.build/bin/autotest ${STAGEDIR}${PREFIX}/bin - ${INSTALL_PROGRAM} ${WRKDIR}/.build/bin/zenoedit ${STAGEDIR}${PREFIX}/bin - ${INSTALL_LIB} ${WRKDIR}/.build/bin/libzeno.so ${STAGEDIR}${PREFIX}/lib + ${INSTALL_PROGRAM} ${BUILD_WRKSRC}/bin/autotest ${STAGEDIR}${PREFIX}/bin + ${INSTALL_PROGRAM} ${BUILD_WRKSRC}/bin/zenoedit ${STAGEDIR}${PREFIX}/bin + ${INSTALL_LIB} ${BUILD_WRKSRC}/bin/libzeno.so ${STAGEDIR}${PREFIX}/lib .include <bsd.port.mk> diff --git a/graphics/zeno/distinfo b/graphics/zeno/distinfo index 9c65acf14c09..27ddea15c59c 100644 --- a/graphics/zeno/distinfo +++ b/graphics/zeno/distinfo @@ -1,3 +1,15 @@ -TIMESTAMP = 1731578367 +TIMESTAMP = 1732976904 SHA256 (zenustech-zeno-2024.10.1_GH0.tar.gz) = ae44fd0ac2aabf225718ffa4d10a057b4ad088534f81df19682b77701dfca139 SIZE (zenustech-zeno-2024.10.1_GH0.tar.gz) = 101700063 +SHA256 (zenustech-openvdb-74a95a74d91e0115be00d7b94391f5607e02d60f_GH0.tar.gz) = eb57b050e06ebf9d900a537f3d57b0d1b359ffeba8a347773dba3f4618041698 +SIZE (zenustech-openvdb-74a95a74d91e0115be00d7b94391f5607e02d60f_GH0.tar.gz) = 3816032 +SHA256 (zenustech-assimp-745fcc9ba0c79feb4edfc71f464d6d4c920ecc06_GH0.tar.gz) = ed5017b2f8bdee0f117ed9ada0ea0f4e67705bd264e9bb0a086d89a9fcac3834 +SIZE (zenustech-assimp-745fcc9ba0c79feb4edfc71f464d6d4c920ecc06_GH0.tar.gz) = 46626516 +SHA256 (zenustech-dem-bones-bin-30a39493f0394dfedc5d72ea463405b8f07a446e_GH0.tar.gz) = 813a7a3c9d66527881591c716c91cc863ec3b3b4f7e8f176a99dbcbe3aa6d521 +SIZE (zenustech-dem-bones-bin-30a39493f0394dfedc5d72ea463405b8f07a446e_GH0.tar.gz) = 20143407 +SHA256 (zenustech-libigl-9af4b833cb37c0d4b77ca62b7502284b3a83a47e_GH0.tar.gz) = 75156457813f2679696db8bbfaef137fab9b8accd78488d4c49ce50e94e08fcc +SIZE (zenustech-libigl-9af4b833cb37c0d4b77ca62b7502284b3a83a47e_GH0.tar.gz) = 2524253 +SHA256 (zenustech-bullet3-aa4931408428cd72057e59627770fc027c5bb0be_GH0.tar.gz) = 134f6f0baddd84eaf1c0535bfd7c4fb1797ca3897375b513c9fec6a9fbe30abc +SIZE (zenustech-bullet3-aa4931408428cd72057e59627770fc027c5bb0be_GH0.tar.gz) = 1647993 +SHA256 (zenustech-OpenSubdiv-a50680658f9732a41fea8e150310cfb9b147dc3c_GH0.tar.gz) = 4bf359ef175e9ef90296d84cdafef67b748a0a35339fb3b7d2192761f4965f0d +SIZE (zenustech-OpenSubdiv-a50680658f9732a41fea8e150310cfb9b147dc3c_GH0.tar.gz) = 39239132 diff --git a/graphics/zeno/files/patch-ui_zenoui_CMakeLists.txt b/graphics/zeno/files/patch-ui_zenoui_CMakeLists.txt new file mode 100644 index 000000000000..c36e1b678681 --- /dev/null +++ b/graphics/zeno/files/patch-ui_zenoui_CMakeLists.txt @@ -0,0 +1,26 @@ +--- ui/zenoui/CMakeLists.txt.orig 2024-09-30 13:46:54 UTC ++++ ui/zenoui/CMakeLists.txt +@@ -18,8 +18,13 @@ target_include_directories(zenoui PRIVATE ${Qt5Widgets + target_link_libraries(zenoui PUBLIC zeno) + + target_include_directories(zenoui PRIVATE ${Qt5Widgets_PRIVATE_INCLUDE_DIRS}) +-target_include_directories(zenoui PRIVATE . .. ../include ../qwt/include) + ++# hotfix for freebsd ++set(QWT_INCLUDE_DIR "%%LOCALBASE%%/include/qt5/qwt6") ++set(Qt5Qwt6_LIBRARIES "%%LOCALBASE%%/lib/qt5/libqwt.so") ++ ++target_include_directories(zenoui PRIVATE . .. ../include ${QWT_INCLUDE_DIR}) ++ + if (WIN32) + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + target_link_libraries(zenoui PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../qwt/libs/win/qwtd.lib) +@@ -27,5 +32,7 @@ else() + target_link_libraries(zenoui PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../qwt/libs/win/qwt.lib) + endif() + else() +- target_link_libraries(zenoui PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../qwt/libs/linux/libqwt.a) ++ # hotfix for freebsd ++ target_link_libraries(zenoui PRIVATE ${Qt5Qwt6_LIBRARIES}) + endif() ++ diff --git a/graphics/zeno/files/patch-zeno_src_nodes_zeno__animation.cpp b/graphics/zeno/files/patch-zeno_src_nodes_zeno__animation.cpp new file mode 100644 index 000000000000..5e9e6bd3c1c7 --- /dev/null +++ b/graphics/zeno/files/patch-zeno_src_nodes_zeno__animation.cpp @@ -0,0 +1,480 @@ +--- zeno/src/nodes/zeno_animation.cpp.orig 2024-11-30 18:56:29 UTC ++++ zeno/src/nodes/zeno_animation.cpp +@@ -0,0 +1,477 @@ ++// ++// Created by zhouhang on 2024/3/28. ++// ++#include <zeno/zeno.h> ++#include <zeno/types/PrimitiveObject.h> ++#include <zeno/types/NumericObject.h> ++#include <zeno/types/UserData.h> ++#include <zeno/extra/GlobalState.h> ++#include <zeno/utils/log.h> ++#include <zeno/utils/fileio.h> ++#include <glm/glm.hpp> ++#include <glm/gtc/matrix_transform.hpp> ++#include <glm/gtx/transform.hpp> ++#include <glm/gtx/quaternion.hpp> ++#include <numeric> ++namespace zeno { ++struct ReadNeoxModel : INode { ++ virtual void apply() override { ++ auto path = get_input2<std::string>("path"); ++ auto prim = std::make_shared<PrimitiveObject>(); ++ auto reader = BinaryReader(file_get_binary(path)); ++ reader.skip(8); ++ auto bone_exist = reader.read_LE<int32_t>(); ++ std::vector<int> parent_nodes; ++ std::vector<std::string> bone_names; ++ std::vector<glm::mat4> bone_bind_matrix; ++ ++ if (bone_exist) { ++ if (bone_exist > 1) { ++ auto count = reader.read_LE<uint8_t>(); ++ reader.skip(2); ++ reader.skip(count * 4); ++ } ++ auto bone_count = reader.read_LE<uint16_t>(); ++ for (auto i = 0; i < bone_count; i++) { ++ auto parent_node = int(reader.read_LE<uint8_t>()); ++ if (parent_node == 255) { ++ parent_node = -1; ++ } ++ parent_nodes.push_back(parent_node); ++ } ++ for (auto i = 0; i < bone_count; i++) { ++ auto bone_name = reader.read_string(32); ++ bone_names.push_back(bone_name); ++ } ++ auto bone_extra_info = reader.read_LE<uint8_t>(); ++ if (bone_extra_info) { ++ reader.skip(28 * bone_count); ++ } ++ for (auto i = 0; i < bone_count; i++) { ++ auto bind_matrix = reader.read_LE<glm::mat4>(); ++ bone_bind_matrix.push_back(bind_matrix); ++ } ++ auto _flag = reader.read_LE<uint8_t>(); ++ if (_flag != 0) { ++ zeno::log_error("assert error"); ++ } ++ } ++ prim->userData().set2("boneName_count", int(bone_names.size())); ++ for (auto i = 0; i < bone_names.size(); i++) { ++ prim->userData().set2(format("boneName_{}", i), bone_names[i]); ++ } ++ std::vector<vec4i> meshes; ++ { ++ auto _offset = reader.read_LE<uint32_t>(); ++ while (true) { ++ auto flag = reader.read_LE<uint16_t>(); ++ if (flag == 1) { ++ break; ++ } ++ reader.skip(-2); ++ auto mesh_vertex_count = reader.read_LE<uint32_t>(); ++ auto mesh_face_count = reader.read_LE<uint32_t>(); ++ auto uv_layers = reader.read_LE<uint8_t>(); ++ auto color_len = reader.read_LE<uint8_t>(); ++ meshes.emplace_back(mesh_vertex_count, mesh_face_count, uv_layers, color_len); ++ } ++ } ++ auto vertex_count = reader.read_LE<uint32_t>(); ++ auto face_count = reader.read_LE<uint32_t>(); ++ prim->verts.resize(vertex_count); ++ for (auto i = 0; i < vertex_count; i++) { ++ prim->verts[i] = reader.read_LE<vec3f>() * vec3f(-1, 1, 1); ++ } ++ auto &nrm = prim->verts.add_attr<vec3f>("nrm"); ++ for (auto i = 0; i < vertex_count; i++) { ++ nrm[i] = reader.read_LE<vec3f>(); ++ } ++ auto flag = reader.read_LE<uint16_t>(); ++ if (flag) { ++ reader.skip(vertex_count * 12); ++ } ++ prim->tris.resize(face_count); ++ for (auto i = 0; i < face_count; i++) { ++ auto f0 = int(reader.read_LE<uint16_t>()); ++ auto f1 = int(reader.read_LE<uint16_t>()); ++ auto f2 = int(reader.read_LE<uint16_t>()); ++ prim->tris[i] = {f0, f2, f1}; ++ } ++ for (auto [mesh_vertex_count, mesh_face_count, uv_layers, color_len]: meshes) { ++ reader.skip(mesh_vertex_count * 8 * uv_layers); ++ } ++ for (auto [mesh_vertex_count, mesh_face_count, uv_layers, color_len]: meshes) { ++ reader.skip(mesh_vertex_count * 4 * color_len); ++ } ++ ++ int start = reader.current(); ++ if (bone_exist) { ++ auto &bi = prim->verts.add_attr<vec4i>("boneName"); ++ for (auto i = 0; i < prim->verts.size(); i++) { ++ auto _0 = int(reader.read_LE<uint8_t>()); ++ auto _1 = int(reader.read_LE<uint8_t>()); ++ auto _2 = int(reader.read_LE<uint8_t>()); ++ auto _3 = int(reader.read_LE<uint8_t>()); ++ bi[i] = {_0, _1, _2, _3}; ++ for (auto j = 0; j < 4; j++) { ++ if (bi[i][j] == 255) { ++ bi[i][j] = -1; ++ } ++ } ++ } ++ auto &bw = prim->verts.add_attr<vec4f>("boneWeight"); ++ for (auto i = 0; i < prim->verts.size(); i++) { ++ bw[i] = { ++ reader.read_LE<float>(), ++ reader.read_LE<float>(), ++ reader.read_LE<float>(), ++ reader.read_LE<float>(), ++ }; ++ } ++ } ++ ++ set_output("prim", prim); ++ auto bones = std::make_shared<PrimitiveObject>(); ++ ++ bones->verts.resize(bone_names.size()); ++ auto &transform_r0 = bones->verts.add_attr<vec3f>("transform_r0"); ++ auto &transform_r1 = bones->verts.add_attr<vec3f>("transform_r1"); ++ auto &transform_r2 = bones->verts.add_attr<vec3f>("transform_r2"); ++ for (auto i = 0; i < bones->verts.size(); i++) { ++ auto bind_matrix = bone_bind_matrix[i]; ++ glm::mat4 m(1); ++ m[0][0] = -1; ++ bind_matrix = m * bind_matrix; ++ transform_r0[i] = {bind_matrix[0][0], bind_matrix[0][1], bind_matrix[0][2]}; ++ transform_r1[i] = {bind_matrix[1][0], bind_matrix[1][1], bind_matrix[1][2]}; ++ transform_r2[i] = zeno::cross(transform_r0[i], transform_r1[i]); ++ auto pos = bind_matrix[3]; ++ bones->verts[i] = {pos[0], pos[1], pos[2]}; ++ } ++ std::vector<int> loops; ++ for (auto i = 0; i < parent_nodes.size(); i++) { ++ if (parent_nodes[i] != -1) { ++ loops.push_back(parent_nodes[i]); ++ loops.push_back(i); ++ } ++ } ++ bones->loops = loops; ++ bones->polys.resize(loops.size() / 2); ++ for (auto i = 0; i < bones->polys.size(); i++) { ++ bones->polys[i] = {i * 2, 2}; ++ } ++ ++ bones->userData().set2("boneName_count", int(bone_names.size())); ++ for (auto i = 0; i < bone_names.size(); i++) { ++ bones->userData().set2(format("boneName_{}", i), bone_names[i]); ++ } ++ set_output("bones", bones); ++ } ++}; ++ ++ZENDEFNODE(ReadNeoxModel, { ++ { ++ {"readpath", "path"}, ++ }, ++ { ++ "prim", ++ "bones", ++ }, ++ {}, ++ {"Neox"}, ++}); ++ ++struct BoneTran { ++ glm::vec3 pos; ++ glm::quat rot; ++ glm::vec3 scale; ++ glm::mat4 to_matrix() { ++ glm::mat4 matTrans = glm::translate(pos); ++ glm::mat4 matQuat = glm::toMat4(rot); ++ glm::mat4 matScal = glm::scale( scale); ++ return matTrans * matQuat * matScal; ++ } ++}; ++struct AnimInfo { ++ uint32_t fps; ++ uint8_t is_loop; ++ uint8_t has_scaled; ++ uint16_t prs_flags; ++ uint32_t accum_flags; ++ uint8_t pack_prs_flags; ++ uint8_t bone_separate_flags; ++ void read_from_reader(BinaryReader &reader) { ++ fps = reader.read_LE<uint32_t>(); ++ is_loop = reader.read_LE<uint8_t>(); ++ has_scaled = reader.read_LE<uint8_t>(); ++ prs_flags = reader.read_LE<uint16_t>(); ++ accum_flags = reader.read_LE<uint32_t>(); ++ pack_prs_flags = reader.read_LE<uint8_t>(); ++ bone_separate_flags = reader.read_LE<uint8_t>(); ++ } ++}; ++struct ReadNeoxAnimation : INode { ++ virtual void apply() override { ++ auto path = get_input2<std::string>("path"); ++ auto anim = std::make_shared<PrimitiveObject>(); ++ auto reader = BinaryReader(file_get_binary(path)); ++ reader.skip(4); ++ auto _version = reader.read_LE<uint32_t>(); ++ auto anim_count = reader.read_LE<uint16_t>(); ++ anim->userData().set2("anim_count", int(anim_count)); ++ auto bone_count = reader.read_LE<uint32_t>(); ++ anim->userData().set2("boneName_count", int(bone_count)); ++ std::vector<std::string> bone_names; ++ for (auto i = 0; i < bone_count; i++) { ++ auto bone_name = reader.read_string(32); ++ bone_names.push_back(bone_name); ++ } ++ anim->userData().set2("boneName_count", int(bone_names.size())); ++ for (auto i = 0; i < bone_names.size(); i++) { ++ anim->userData().set2(format("boneName_{}", i), bone_names[i]); ++ } ++ std::vector<BoneTran> bone_transs; ++ for (auto i = 0; i < bone_count; i++) { ++ BoneTran bone_trans; ++ bone_trans.pos = reader.read_LE<glm::vec3>(); ++ bone_trans.rot = reader.read_LE<glm::quat>(); ++ bone_trans.scale = reader.read_LE<glm::vec3>(); ++ bone_transs.push_back(bone_trans); ++ } ++ auto separate_storage = reader.read_LE<uint16_t>(); ++ auto _base_size = reader.read_LE<uint16_t>(); ++ if (separate_storage > 0) { ++ reader.read_LE<uint32_t>(); ++ } ++ for (auto i = 0; i < anim_count; i++) { ++ auto anim_name = reader.read_string(32); ++ anim->userData().set2(format("anim_name_{}", i), anim_name); ++ auto anim_root_name = reader.read_string(32); ++ anim->userData().set2(format("anim_root_name_{}", i), anim_root_name); ++ auto bone_count = reader.read_LE<uint16_t>(); ++ reader.skip(1020); ++ AnimInfo animInfo; ++ animInfo.read_from_reader(reader); ++ reader.skip(8); ++ } ++ ++ set_output("anim", anim); ++ } ++}; ++ ++ZENDEFNODE(ReadNeoxAnimation, { ++ { ++ {"readpath", "path"}, ++ }, ++ { ++ "anim", ++ }, ++ {}, ++ {"Neox"}, ++}); ++glm::vec3 read_half3(BinaryReader &reader) { ++ auto x = glm::detail::toFloat32(reader.read_LE<int16_t>()); ++ auto y = glm::detail::toFloat32(reader.read_LE<int16_t>()); ++ auto z = glm::detail::toFloat32(reader.read_LE<int16_t>()); ++ return {x, y, z}; ++} ++glm::quat read_half_quat(BinaryReader &reader) { ++ auto x = glm::detail::toFloat32(reader.read_LE<int16_t>()); ++ auto y = glm::detail::toFloat32(reader.read_LE<int16_t>()); ++ auto z = glm::detail::toFloat32(reader.read_LE<int16_t>()); ++ auto w = glm::detail::toFloat32(reader.read_LE<int16_t>()); ++ return {w, x, y, z}; ++} ++struct ReadNeoxSubAnimation : INode { ++ void search(int ci, std::vector<glm::mat4> &matrixs, std::map<int, int> &c2p, std::map<int, glm::mat4> &result) { ++ zeno::log_info("{}", ci); ++ if (result.count(ci)) { ++ zeno::log_info("result found"); ++ return; ++ } ++ if (c2p.count(ci) == 0) { ++ zeno::log_info("not parent"); ++ result[ci] = matrixs[ci]; ++ zeno::log_info("use matrixs"); ++ } ++ else { ++ auto pi = c2p[ci]; ++ if (result.count(pi) == 0) { ++ search(pi, matrixs, c2p, result); ++ } ++ result[ci] = result[pi] * matrixs[ci]; ++ } ++ } ++ virtual void apply() override { ++ int frameid; ++ if (has_input("frameid")) { ++ frameid = std::lround(get_input2<float>("frameid")); ++ } else { ++ frameid = getGlobalState()->frameid; ++ } ++ auto path = get_input2<std::string>("path"); ++ auto anim = std::make_shared<PrimitiveObject>(); ++ auto reader = BinaryReader(file_get_binary(path)); ++ auto anim_name = reader.read_string(32); ++ anim->userData().set2("anim_name", anim_name); ++ ++ auto anim_root_name = reader.read_string(32); ++ auto bone_count = reader.read_LE<uint16_t>(); ++ std::vector<std::string> bone_names; ++ for (auto i = 0; i < bone_count; i++) { ++ auto bone_name = reader.read_string(32); ++ bone_names.push_back(bone_name); ++ } ++ anim->userData().set2("boneName_count", int(bone_names.size())); ++ for (auto i = 0; i < bone_names.size(); i++) { ++ anim->userData().set2(format("boneName_{}", i), bone_names[i]); ++ } ++ AnimInfo animInfo; ++ animInfo.read_from_reader(reader); ++ auto key_count = reader.read_LE<uint16_t>(); ++ frameid = zeno::clamp(frameid, 0, key_count - 1); ++ anim->userData().set2("key_count", int(key_count)); ++ for (auto i = 0; i < key_count; i++) { ++ auto key_time = reader.read_LE<float>(); ++ } ++ anim->verts.resize(bone_count); ++ auto &boneName = anim->verts.add_attr<int>("boneName"); ++ std::iota(boneName.begin(), boneName.end(), 0); ++ auto &transform_r0 = anim->verts.add_attr<vec3f>("transform_r0"); ++ auto &transform_r1 = anim->verts.add_attr<vec3f>("transform_r1"); ++ auto &transform_r2 = anim->verts.add_attr<vec3f>("transform_r2"); ++ auto &raw_pos = anim->verts.add_attr<vec3f>("raw_pos"); ++ auto &raw_rot = anim->verts.add_attr<vec4f>("raw_rot"); ++ auto &raw_scale = anim->verts.add_attr<vec3f>("raw_scale"); ++ auto &_has_pos_keys = anim->verts.add_attr<int>("has_pos_keys"); ++ auto &_has_rot_keys = anim->verts.add_attr<int>("has_rot_keys"); ++ auto &_has_scale_keys = anim->verts.add_attr<int>("has_scale_keys"); ++ std::vector<glm::mat4> matrixs; ++ for (auto i = 0; i < bone_count; i++) { ++ auto has_pos_keys = reader.read_LE<uint8_t>(); ++ auto has_rot_keys = reader.read_LE<uint8_t>(); ++ auto has_scale_keys = reader.read_LE<uint8_t>(); ++ _has_pos_keys[i] = int(has_pos_keys); ++ _has_rot_keys[i] = int(has_rot_keys); ++ _has_scale_keys[i] = int(has_scale_keys); ++ auto euler_flags = reader.read_LE<uint8_t>(); ++ BoneTran boneTran = {}; ++ if (has_pos_keys) { ++ for (auto j = 0; j < key_count; j++) { ++ auto pos = reader.read_LE<glm::vec3>(); ++ if (j == frameid) { ++ boneTran.pos = pos; ++ } ++ } ++ } else { ++ boneTran.pos = reader.read_LE<glm::vec3>(); ++ } ++ ++ if (has_rot_keys) { ++ for (auto j = 0; j < key_count; j++) { ++ auto rot = read_half_quat(reader); ++ if (j == frameid) { ++ boneTran.rot = rot; ++ } ++ } ++ } else { ++ boneTran.rot = read_half_quat(reader); ++ } ++ if (has_scale_keys) { ++ for (auto j = 0; j < key_count; j++) { ++ auto scale = read_half3(reader); ++ if (j == frameid) { ++ boneTran.scale = scale; ++ } ++ } ++ } else { ++ boneTran.scale = read_half3(reader); ++ } ++ for (auto j = 0; j < 3; j++) { ++ if (std::abs(boneTran.pos[j]) < 0.001) { ++ boneTran.pos[j] = 0; ++ } ++ if (std::abs(boneTran.scale[j] - 1) < 0.001) { ++ boneTran.scale[j] = 1; ++ } ++ } ++ for (auto j = 0; j < 4; j++) { ++ if (std::abs(boneTran.rot[j]) < 0.001) { ++ boneTran.rot[j] = 0; ++ } ++ if (std::abs(boneTran.rot[j] - 1) < 0.001) { ++ boneTran.rot[j] = 1; ++ } ++ } ++ ++ auto matrix = boneTran.to_matrix(); ++ matrixs.push_back(matrix); ++ transform_r0[i] = {matrix[0][0], matrix[0][1], matrix[0][2]}; ++ transform_r1[i] = {matrix[1][0], matrix[1][1], matrix[1][2]}; ++ transform_r2[i] = {matrix[2][0], matrix[2][1], matrix[2][2]}; ++ auto pos = matrix[3]; ++ anim->verts[i] = {pos[0], pos[1], pos[2]}; ++ raw_pos[i] = other_to_vec<3>(boneTran.pos); ++ raw_rot[i] = other_to_vec<4>(boneTran.rot); ++ raw_scale[i] = other_to_vec<3>(boneTran.scale); ++ } ++ if (has_input("skeleton")) { ++ std::vector<int> loops; ++ std::map<int, int> c2p; ++ auto skeleton = get_input2<PrimitiveObject>("skeleton"); ++ for (auto i = 0; i < skeleton->polys.size(); i++) { ++ auto p = skeleton->loops[i * 2 + 0]; ++ auto c = skeleton->loops[i * 2 + 1]; ++ auto pn = skeleton->userData().get2<std::string>(format("boneName_{}", p)); ++ auto cn = skeleton->userData().get2<std::string>(format("boneName_{}", c)); ++ auto pi = std::find(bone_names.begin(), bone_names.end(), pn) - bone_names.begin(); ++ auto ci = std::find(bone_names.begin(), bone_names.end(), cn) - bone_names.begin(); ++ if (pi != bone_names.size() && ci != bone_names.size()) { ++ loops.push_back(pi); ++ loops.push_back(ci); ++ c2p[ci] = pi; ++ } ++ } ++ anim->loops = loops; ++ anim->polys.resize(loops.size() / 2); ++ for (auto i = 0; i < anim->polys.size(); i++) { ++ anim->polys[i] = {i * 2, 2}; ++ } ++ std::map<int, glm::mat4> result; ++ ++ for (auto i = 0; i < anim->polys.size(); i++) { ++ search(anim->loops[2 * i + 1], matrixs, c2p, result); ++ } ++ for (auto i = 0; i < anim->verts.size(); i++) { ++ auto matrix = matrixs[i]; ++ ++ if (result.count(i)) { ++ matrix = result[i]; ++ } ++ glm::mat4 m(1); ++ m[0][0] = -1; ++ matrix = m * matrix; ++ transform_r0[i] = {matrix[0][0], matrix[0][1], matrix[0][2]}; ++ transform_r1[i] = {matrix[1][0], matrix[1][1], matrix[1][2]}; ++ transform_r2[i] = zeno::cross(transform_r0[i], transform_r1[i]); ++ auto pos = matrix[3]; ++ anim->verts[i] = {pos[0], pos[1], pos[2]}; ++ } ++ } ++ set_output("anim", anim); ++ } ++}; ++ ++ZENDEFNODE(ReadNeoxSubAnimation, { ++ { ++ {"readpath", "path"}, ++ {"frameid"}, ++ "skeleton", ++ }, ++ { ++ "anim", ++ }, ++ {}, ++ {"Neox"}, ++}); ++}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202412170058.4BH0wsDx094632>