From nobody Tue Dec 17 00:58:54 2024 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YBz332qVcz5gp2T; Tue, 17 Dec 2024 00:58:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YBz330Ybqz4P7d; Tue, 17 Dec 2024 00:58:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734397135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EkO/yYLpb4LOyVIabPKjkFCkWkcWzyQyyMEvHw65BcI=; b=mLXbx4zgZM7fmuOFkcCwxvNSsijGbp/G5rrBNnTxW7sJXhl84YGeOdjv0LuNl3H65BdOos EbmESWrw019G+en104kowqq5m2jXuGYwEll7LHBSGHuRfaqdp7xZfh6qnjBaadqPKS3k1h 6NOs8DV7xB8NhPwtKqrgRt5HGZaeqlT2pcBsm6wjvzLGPIZv58wLEsFe6qcB1yJf9h/dHK wqi4sK72HHmkBzbeehPeHE6I9Tkvc3cv+ch+3NJspjIH33tXZaF23kaL1Ou/n+X3VIzxNr XlCL/QWIji0iluo4EznkptqS3NnHsWer7fYiIckLAiimPhBk9/PN4U9oyVFcMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734397135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EkO/yYLpb4LOyVIabPKjkFCkWkcWzyQyyMEvHw65BcI=; b=MwTrpd+7K+GPmRwfFrhn+OAEZCik/TY2ZohmUpW94VQM+xgkX4b8S9lmdBj9j4+bYWgGEN RQPptil6gdCKyfJYtOV9qAYmE8TpQXVGATwnyferXBAq4bWIrqSFPY8ZGnLsZVPP0Ov23j o8pR1fc2//RYIyoLO8pvvboLuDWIXWd4ThT+ULCVkGnugvxH/RrH+ZIbZiJlxYfr0TMawP jvHYYGs18KGMFkT0QXrNvEXHj8mFmzaFKWHHIMpMk53nVsOqOIyGW2fYTqoWuSubZ2Ge5d d3bBlx/kRYxfXzxZ4Vwqv8gJ7LQKblZkq9aVK4L6pLqR+1c9ArsmXXXgXi5dUA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734397135; a=rsa-sha256; cv=none; b=QQ/YMgA3v/NMWBO3j/JKW9XcKRuMzU1YX/YTsj09J3OgfPnJXJBmmaG9GjFkMDdpssbezB 0Bh1K3guTJd/mAwDvG8+wImhfVwTGYhOqv1HzLZupEfwOimomSRqUweq43M3FlvTuZuu39 R3/ruAvdSGi3IHUL911Z9MSGMz0y4k86rRxnI+Tn6dP4Au8hwgtCnGnzmJ/Pd6sha384Aq C3CO+TddL1WVBSG2zcIDkVnXMacnDMKhRcxEKwkF4WgfoeXn+335aWS2qqhPfJTwmgY25Z ceLkTjHKjbtHMnVGinSaLGZVfoPT+8tSl+A7zz2WrRMIPPgvS7pYG2J5reXjAg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YBz3270lqz1GNm; Tue, 17 Dec 2024 00:58:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BH0ws11094635; Tue, 17 Dec 2024 00:58:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BH0wsDx094632; Tue, 17 Dec 2024 00:58:54 GMT (envelope-from git) Date: Tue, 17 Dec 2024 00:58:54 GMT Message-Id: <202412170058.4BH0wsDx094632@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Robert Clausecker Subject: git: 9f3642523e98 - main - graphics/zeno: enabled more features List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-ports-main@freebsd.org Sender: owner-dev-commits-ports-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: fuz X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9f3642523e98ddbebc4a2a30c72f3f9b0b6e3cfc Auto-Submitted: auto-generated The branch main has been updated by fuz: URL: https://cgit.FreeBSD.org/ports/commit/?id=9f3642523e98ddbebc4a2a30c72f3f9b0b6e3cfc commit 9f3642523e98ddbebc4a2a30c72f3f9b0b6e3cfc Author: Martin Filla AuthorDate: 2024-12-01 08:02:19 +0000 Commit: Robert Clausecker 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 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 ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++namespace zeno { ++struct ReadNeoxModel : INode { ++ virtual void apply() override { ++ auto path = get_input2("path"); ++ auto prim = std::make_shared(); ++ auto reader = BinaryReader(file_get_binary(path)); ++ reader.skip(8); ++ auto bone_exist = reader.read_LE(); ++ std::vector parent_nodes; ++ std::vector bone_names; ++ std::vector bone_bind_matrix; ++ ++ if (bone_exist) { ++ if (bone_exist > 1) { ++ auto count = reader.read_LE(); ++ reader.skip(2); ++ reader.skip(count * 4); ++ } ++ auto bone_count = reader.read_LE(); ++ for (auto i = 0; i < bone_count; i++) { ++ auto parent_node = int(reader.read_LE()); ++ 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(); ++ if (bone_extra_info) { ++ reader.skip(28 * bone_count); ++ } ++ for (auto i = 0; i < bone_count; i++) { ++ auto bind_matrix = reader.read_LE(); ++ bone_bind_matrix.push_back(bind_matrix); ++ } ++ auto _flag = reader.read_LE(); ++ 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 meshes; ++ { ++ auto _offset = reader.read_LE(); ++ while (true) { ++ auto flag = reader.read_LE(); ++ if (flag == 1) { ++ break; ++ } ++ reader.skip(-2); ++ auto mesh_vertex_count = reader.read_LE(); ++ auto mesh_face_count = reader.read_LE(); ++ auto uv_layers = reader.read_LE(); ++ auto color_len = reader.read_LE(); ++ meshes.emplace_back(mesh_vertex_count, mesh_face_count, uv_layers, color_len); ++ } ++ } ++ auto vertex_count = reader.read_LE(); ++ auto face_count = reader.read_LE(); ++ prim->verts.resize(vertex_count); ++ for (auto i = 0; i < vertex_count; i++) { ++ prim->verts[i] = reader.read_LE() * vec3f(-1, 1, 1); ++ } ++ auto &nrm = prim->verts.add_attr("nrm"); ++ for (auto i = 0; i < vertex_count; i++) { ++ nrm[i] = reader.read_LE(); ++ } ++ auto flag = reader.read_LE(); ++ 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()); ++ auto f1 = int(reader.read_LE()); ++ auto f2 = int(reader.read_LE()); ++ 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("boneName"); ++ for (auto i = 0; i < prim->verts.size(); i++) { ++ auto _0 = int(reader.read_LE()); ++ auto _1 = int(reader.read_LE()); ++ auto _2 = int(reader.read_LE()); ++ auto _3 = int(reader.read_LE()); ++ 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("boneWeight"); ++ for (auto i = 0; i < prim->verts.size(); i++) { ++ bw[i] = { ++ reader.read_LE(), ++ reader.read_LE(), ++ reader.read_LE(), ++ reader.read_LE(), ++ }; ++ } ++ } ++ ++ set_output("prim", prim); ++ auto bones = std::make_shared(); ++ ++ bones->verts.resize(bone_names.size()); ++ auto &transform_r0 = bones->verts.add_attr("transform_r0"); ++ auto &transform_r1 = bones->verts.add_attr("transform_r1"); ++ auto &transform_r2 = bones->verts.add_attr("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 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(); ++ is_loop = reader.read_LE(); ++ has_scaled = reader.read_LE(); ++ prs_flags = reader.read_LE(); ++ accum_flags = reader.read_LE(); ++ pack_prs_flags = reader.read_LE(); ++ bone_separate_flags = reader.read_LE(); ++ } ++}; ++struct ReadNeoxAnimation : INode { ++ virtual void apply() override { ++ auto path = get_input2("path"); ++ auto anim = std::make_shared(); ++ auto reader = BinaryReader(file_get_binary(path)); ++ reader.skip(4); ++ auto _version = reader.read_LE(); ++ auto anim_count = reader.read_LE(); ++ anim->userData().set2("anim_count", int(anim_count)); ++ auto bone_count = reader.read_LE(); ++ anim->userData().set2("boneName_count", int(bone_count)); ++ std::vector 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 bone_transs; ++ for (auto i = 0; i < bone_count; i++) { ++ BoneTran bone_trans; ++ bone_trans.pos = reader.read_LE(); ++ bone_trans.rot = reader.read_LE(); ++ bone_trans.scale = reader.read_LE(); ++ bone_transs.push_back(bone_trans); ++ } ++ auto separate_storage = reader.read_LE(); ++ auto _base_size = reader.read_LE(); ++ if (separate_storage > 0) { ++ reader.read_LE(); ++ } ++ 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(); ++ 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()); ++ auto y = glm::detail::toFloat32(reader.read_LE()); ++ auto z = glm::detail::toFloat32(reader.read_LE()); ++ return {x, y, z}; ++} ++glm::quat read_half_quat(BinaryReader &reader) { ++ auto x = glm::detail::toFloat32(reader.read_LE()); ++ auto y = glm::detail::toFloat32(reader.read_LE()); ++ auto z = glm::detail::toFloat32(reader.read_LE()); ++ auto w = glm::detail::toFloat32(reader.read_LE()); ++ return {w, x, y, z}; ++} ++struct ReadNeoxSubAnimation : INode { ++ void search(int ci, std::vector &matrixs, std::map &c2p, std::map &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("frameid")); ++ } else { ++ frameid = getGlobalState()->frameid; ++ } ++ auto path = get_input2("path"); ++ auto anim = std::make_shared(); ++ 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(); ++ std::vector 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(); ++ 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(); ++ } ++ anim->verts.resize(bone_count); ++ auto &boneName = anim->verts.add_attr("boneName"); ++ std::iota(boneName.begin(), boneName.end(), 0); ++ auto &transform_r0 = anim->verts.add_attr("transform_r0"); ++ auto &transform_r1 = anim->verts.add_attr("transform_r1"); ++ auto &transform_r2 = anim->verts.add_attr("transform_r2"); ++ auto &raw_pos = anim->verts.add_attr("raw_pos"); ++ auto &raw_rot = anim->verts.add_attr("raw_rot"); ++ auto &raw_scale = anim->verts.add_attr("raw_scale"); ++ auto &_has_pos_keys = anim->verts.add_attr("has_pos_keys"); ++ auto &_has_rot_keys = anim->verts.add_attr("has_rot_keys"); ++ auto &_has_scale_keys = anim->verts.add_attr("has_scale_keys"); ++ std::vector matrixs; ++ for (auto i = 0; i < bone_count; i++) { ++ auto has_pos_keys = reader.read_LE(); ++ auto has_rot_keys = reader.read_LE(); ++ auto has_scale_keys = reader.read_LE(); ++ _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(); ++ BoneTran boneTran = {}; ++ if (has_pos_keys) { ++ for (auto j = 0; j < key_count; j++) { ++ auto pos = reader.read_LE(); ++ if (j == frameid) { ++ boneTran.pos = pos; ++ } ++ } ++ } else { ++ boneTran.pos = reader.read_LE(); ++ } ++ ++ 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 loops; ++ std::map c2p; ++ auto skeleton = get_input2("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(format("boneName_{}", p)); ++ auto cn = skeleton->userData().get2(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 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"}, ++}); ++}