Unity-based 3D model and animation file bidirectional operation method and related products

By importing FBX files into the Unity engine and calling native methods of the FBX SDK to edit nodes, the read-only nature of FBX files in Unity is resolved, enabling bidirectional operations on FBX files and improving the efficiency and flexibility of game development.

CN119540411BActive Publication Date: 2025-10-28SHANGHAI YUDIE INTELLIGENT TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411650988.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2025-10-28
Estimated Expiration
2044-11-19

AI Technical Summary

Technical Problem

The Unity engine's handling of FBX files is limited to read-only mode, preventing in-depth editing and modification. This increases the complexity and time cost of the development process, and restricts the application of advanced technologies such as motion capture in game development.

Method used

Import the FBX file using a Unity script, traverse the nodes and call the native methods of the FBX SDK to edit the nodes, including modifying the 3D model structure and animations, and then export the file after editing.

Benefits of technology

It enables bidirectional manipulation of FBX files within Unity, allowing developers to edit and export modified files within the engine, reducing the need for frequent switching between different tools and improving development efficiency and flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119540411B_ABST
    Figure CN119540411B_ABST
Patent Text Reader

Abstract

This application provides a two-way operation mechanism for 3D models and animation files based on Unity, and related products. It imports FBX files via Unity scripts, obtains different types of nodes within the FBX file, and edits these nodes. After editing, the modified FBX file is exported as a new 3D model and animation file. This technical solution enables reading and writing FBX files within Unity; that is, it not only allows importing FBX files into Unity for use but also editing them within Unity and exporting the modified results as a new FBX file. This makes FBX an efficient medium for resource transfer, motion capture, and other functions within Unity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer animation production and editing technology, specifically to a two-way operation of Unity-based 3D models and animation files, and related products. Background Technology

[0002] FBX files, a proprietary file format of Autodesk, are widely used in modeling and game engine development. They are a universal file format that integrates model and animation data. Due to their strong compatibility and rich data expression capabilities, FBX files have become an indispensable part of modern game development and 3D modeling. Many well-known software programs and platforms support the import and export of FBX files, making this format crucial for cross-platform and cross-software resource sharing and collaborative work.

[0003] However, the handling of FBX files in Unity, a popular game development engine, faces certain limitations. While Unity can automatically read and display models, animations, and other components after importing an FBX file, developers can only perform limited read-only operations on these components. Specifically, Unity's support for FBX files is mainly focused on display and playback; deeper editing and modification, such as animation editing, adding or removing model nodes, and deleting meshes, are not supported.

[0004] This limitation has caused numerous inconveniences in game development and software production. For example, during development, developers may need to adjust and optimize models or animations in FBX files according to actual needs, but Unity does not directly provide these editing functions. This forces developers to return to their original modeling software for modifications and then re-export the FBX files, undoubtedly increasing the complexity and time cost of the development process. Furthermore, as game development demands increasingly high-quality animations and complex models, advanced technologies such as motion capture are being increasingly applied in game production. However, Unity's read-only restriction on FBX files limits the application of these technologies on the Unity platform, preventing them from fully realizing their advantages. Summary of the Invention

[0005] The purpose of this application is to provide a two-way operation of 3D models and animation files based on Unity and related products, which solves the problem that 3D models and animation files in Unity can only be read-only and cannot be edited.

[0006] To achieve the above objectives, this application adopts the following technical solution:

[0007] A method for bidirectional manipulation of 3D models and animation files based on Unity includes: importing an FBX file via a Unity script to import the data of the FBX file into FbxScene; traversing the nodes of the FBX file in FbxScene to obtain nodes of different types, or calling native methods of the FBX SDK to obtain nodes of a specified type in FbxScene, and performing editing operations on the nodes; the editing process includes modifying the 3D model structure, skinning, and animation; after editing is completed, exporting the modified FBX file as a new 3D model and animation file.

[0008] In some implementations, importing the FBX file through a Unity script includes: sequentially creating interconnected FbxManager, FbxScene, FbxIOSettings, and FbxImporter in the Unity script; initializing FbxImporter; using FbxImporter to import the data of the FBX file into FbxScene; checking all callback parts and import function return values ​​during the import process; if all callback parts and import function return values ​​are true, it indicates that the FBX file has been successfully imported into Unity.

[0009] In some implementations, traversing the nodes of the FBX file in FbxScene to obtain different types of nodes includes: obtaining the root node of the imported FBX file; recursively traversing each node and its child nodes starting from the root node; obtaining the number of child nodes; obtaining the child node at a specified index; and recursively calling the traversal method until all nodes have been traversed.

[0010] In some implementations, the step of calling the native methods of the FBX SDK to obtain nodes of a specified type in FbxScene includes: obtaining global settings or animation components through native methods of the FBX SDK, and then obtaining the nodes of the specified type.

[0011] In some implementations, the process of editing the nodes and modifying the 3D model structure includes: obtaining the node attributes of the node to be processed; calling a method to determine the node type based on the node attributes to determine whether the node type is eMesh; if the node type is eMesh, obtaining the Mesh object of the node and deleting the corresponding Mesh component as needed; and recursively processing all child nodes. Similarly, other types of nodes, such as model nodes, can also be deleted or edited.

[0012] In some implementations, the editing operation on the node and the modification process of the animation include: modifying the animation components in the FBX file, the animation components including the animation frame rate, animation duration and animation layer; and editing the animation curves in the animation layer, including adding keyframes, setting keyframes and removing keyframes.

[0013] In some implementations, exporting the modified FBX file as a new 3D model and animation file includes: sequentially creating interconnected FbxManager, FbxExporter, and FbxIOSettings in the Unity script; initializing FbxExporter; using FbxExporter to export the data of the FbxScene to a newly created FBX file under a specified path; checking all callback parts and export function return values ​​during the export process; if all callback parts and export function return values ​​are true, it indicates that the FBX file has been successfully exported from Unity.

[0014] The second aspect of this application provides a Unity-based bidirectional operating system for 3D models and animation files, comprising: an import module for importing FBX files into Unity and importing the data of the FBX files into FbxScene; an editing module for traversing the nodes of the FBX files in FbxScene to obtain nodes of different types, or calling native methods of the FBXSDK to obtain nodes of a specified type in FbxScene and performing editing operations on the nodes, the editing process including modifications to the 3D model structure, skinning, and animation; and an export module for exporting the modified FBX files as new 3D model and animation files after editing is completed.

[0015] A third aspect of this application provides a computer-readable storage medium storing a computer program that, when run on a processor, causes the processor to perform the method described in the first aspect.

[0016] A fourth aspect of this application provides an electronic device, comprising: at least one memory for storing a program; and at least one processor for executing the program stored in the memory, wherein when the program stored in the memory is executed, the processor is configured to perform the method as described in the first aspect.

[0017] Compared with the prior art, the beneficial effects of this application are as follows:

[0018] This application provides a two-way manipulation mechanism for 3D models and animation files based on Unity, and related products. It imports FBX files via Unity scripts, iterates through different types of nodes within the FBX file or obtains nodes of a specified type using native methods, and performs editing operations on these nodes. After editing, the modified FBX file is exported as a new 3D model and animation file. This technical solution enables the reading and writing of FBX files within Unity; that is, it not only allows importing FBX files into Unity for use but also editing them within Unity and exporting the modified results as a new FBX file. This makes FBX an efficient medium for resource transfer, motion capture, and other functions within Unity. Attached Figure Description

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.

[0020] Figure 1 A flowchart illustrating a Unity-based bidirectional operation method for 3D models and animation files is shown in an embodiment of this application.

[0021] Figure 2 This illustration shows a schematic diagram of the structure of a Unity-based bidirectional operating system for 3D models and animation files, according to an embodiment of this application. Detailed Implementation

[0022] The technical solutions of the specific embodiments of this application will be further described in detail below with reference to the accompanying drawings. These embodiments are only used to illustrate this application and are not intended to limit this application.

[0023] In this application, the term "and / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent three situations: A existing alone, A and B existing simultaneously, or B existing alone. In this invention, the symbol " / " indicates that the related objects are in an "or" relationship, for example, "A / B" means "A or B".

[0024] The terms "first" and "second," etc., used in the specification and claims of this application are used to distinguish different objects, not to describe a specific order of objects. For example, "first response message" and "second response message," etc., are used to distinguish different response messages, not to describe a specific order of response messages.

[0025] In the embodiments of this application, the words "exemplary" or "for example" are used to indicate that they are examples, illustrations, or descriptions. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be considered as being more preferred or advantageous than other embodiments or design options. Specifically, the use of the words "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0026] In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more, for example, multiple processing units means two or more processing units, multiple elements means two or more elements, etc.

[0027] The following description, in conjunction with the accompanying drawings, details a method for bidirectional manipulation of Unity-based 3D models and animation files, and related products.

[0028] Figure 1 This diagram illustrates a flowchart of a Unity-based bidirectional manipulation method for 3D models and animation files, according to one embodiment of this application. Figure 1 As shown, the method for bidirectional manipulation of 3D models and animation files based on Unity in this application includes the following steps:

[0029] S100 imports FBX files via Unity scripts, importing the data from the FBX files into FbxScene. Specifically, the Autodesk FBX SDK for Unity plugin is installed in Unity's Package Manager. After installation, many methods and interfaces originally provided in the native FBX SDK can be accessed and used. This plugin is adapted and integrated for Unity, making these methods and interfaces more compatible and efficient in the Unity environment. After installing the plugin, the FBXImport() method is called to import the FBX file. This step is a prerequisite for editing 3D models; the FBX file needs to be loaded into the Unity environment for subsequent editing operations.

[0030] The process of importing an FBX file involves creating an FbxManager in the Unity script, as well as creating FbxScene, FbxIOSettings, and FbxImporter, and associating them with the FbxManager sequentially during method calls. FbxScene stores the FBX file data, FbxIOSettings sets import / export options, and FbxImporter performs the file import operation. Initialization calls the FbxImporter.Initialize() method, passing the local FBX file path, file format, and FbxIOSettings as parameters. The FbxImporter.Import() method is then called to import the FBX file data into the passed-in FbxScene. All callbacks and import function return values ​​during the import process are checked; if all callbacks and import function return values ​​are true, the FBX file has been successfully imported via the Unity script.

[0031] Step S200 involves traversing the nodes of the FBX file in FbxScene to obtain nodes of different types, or calling native methods of the FBX SDK to obtain nodes of a specified type from FbxScene, and then performing editing operations on the nodes. The editing process includes modifications to the 3D model structure, skinning, and animation. The aforementioned native methods of the FBX SDK could be, for example, GetGlobalSettings() and GetCurrentAnimationStack(), which obtain global settings or animation components through the native solution of the FBX SDK, thereby obtaining nodes of the specified type. Specifically, traversing the nodes of the FBX file in FbxScene to obtain nodes of different types includes: obtaining the root node of the FBX file through the GetRootNode() method, and recursively traversing each node and its child nodes starting from the root node; obtaining the number of child nodes through GetChildCount(), and recursively calling the traversal method to the child node at a specified index through the GetChild() method until all nodes have been traversed. Traversing all nodes is to find the specific node that needs to be edited, such as removing the Mesh component, by traversing to obtain all nodes (FbxNode).

[0032] FbxNodeAttribute is a tag attribute present in every node, used to distinguish nodes. The GetNodeAttribute() method is called on a node to obtain its FbxNodeAttribute attribute, and the GetAttributeType() method is called on each attribute to obtain the node type. Mesh components can be filtered out by checking if the node attribute is FbxNodeAttribute.EType.eMesh. If the node type is FbxNodeAttribute.EType.eMesh, GetMesh() is called on FbxNode to obtain the FbxMesh, and then Dispose() is called on it to remove the Mesh component. Removing Mesh components is used to remove unwanted geometry when editing FBX files, such as removing the model's mesh in motion capture data. Within this method, GetChildCount() is executed on all nodes to get the number of child nodes, and GetChild() is executed to get the child nodes. Using recursion, all Mesh components within the FBX can be removed. Similarly, other types of nodes, such as model skeleton nodes, can be edited by filtering by name or category.

[0033] Furthermore, the process of importing nodes from FBX files in FbxScene and editing those nodes also includes modifying animations. Specifically, this involves obtaining global settings or animation components using native FBX SDK methods, modifying the animation components in the FBX file (including frame rate, duration, and animation layer), and editing the animation curves within the animation layer, including adding, setting, and removing keyframes.

[0034] Specifically, you can use the `GetGlobalSettings()` method in `FbxScene` to obtain the global settings `FbxGlobalSettings`. These global settings contain basic information about the FBX file, such as the time mode (frame rate), which is crucial for subsequent animation editing operations. Understanding the current frame rate helps maintain consistency when adding or modifying keyframes. You can set or retrieve the animation's frame rate using the `SetTimeMode()` or `GetTimeMode()` methods of `FbxGlobalSettings`. The return parameters and call parameters must be of the `FbxTime.EMode` enumeration type, including commonly used 24, 30, 60, 100, and 120 frames, as well as special values ​​like 72, 96, and 1000 frames.

[0035] Calling the `GetCurrentAnimationStack()` method on `FbxScene` retrieves the overall animation component `FbxAnimStack`. Calling the `SetName()` method of the animation component `FbxAnimStack` allows you to set its name. Animation components are the main structure in an FBX file that stores animation data. Obtaining an animation component is a prerequisite for editing animations; all animation layers and animation curves belong to a specific animation component. Setting the name of the animation component helps in managing and distinguishing multiple animation components. In real-world projects, naming animation components improves readability and maintainability.

[0036] Calling `GetLocalTimeSpan()` or `SetLocalTimeSpan()` on the animation component `FbxAnimStack` allows you to get or set the animation duration. The animation duration defines the start time and the number of segments in the animation. Getting and setting the animation duration helps ensure that the animation plays within the correct time frame. The `FbxTime.FromTime()` method can be used to create more precise time segments, `FbxTimeSpan`, than at the frame level.

[0037] Calling the `GetAnimLayerMember()` method on the animation component `FbxAnimStack` retrieves the animation layer. This animation layer is similar to a `Layer` in Unity's Animation Controller, used to organize and manage different animation data. Obtaining the animation layer is a prerequisite for editing specific animation curves. By sequentially calling `GetMember()`, `GetDstProperty()`, and `GetCurveNode()` methods on the `FbxAnimLayer`, you can obtain `FbxObject`, `FbxProperty`, and `FbxAnimCurveNode` respectively. `GetMember()` requires an `int` parameter of index type; by checking if the return result is null and incrementing it from 0, you can achieve traversal. Obtaining the animation curve nodes is for further editing of specific animation curves. Each `FbxAnimCurveNode` here corresponds to all the animation frames of a certain node in the animation, equivalent to the animation curve of a certain object node within a Unity Animation. The object FbxObject is obtained by calling the GetFbxObject() method of GetDstProperty(), and then the node name is obtained by calling the GetName() method of FbxObject, finally obtaining the node name of type string.

[0038] Calling the `GetName()` method of `FbxAnimCurveNode` returns the definition name of the animation curve type within the FBX file. Common examples include "T", "R", and "S", representing the corresponding operations on the component: Translation (position transformation), Rotation (rotation transformation), and Scale (size transformation). When editing animations, it's sometimes necessary to remove unwanted animation curves. For instance, when a model's property transformation no longer requires animation control, the entire animation curve can be deleted by executing the `Dispose()` method on the `FbxAnimCurveNode`.

[0039] Each animation curve node may contain animation curves along multiple axes, such as the x, y, and z axes. Obtaining the animation curve for a specific axis is for editing the specific animation data along that axis. Specifically, when performing detailed editing of animation curves in an FBX file, the animation curve FbxAnimCurve for a specific axis can be obtained by calling the GetCurve(int pChannelId) method of FbxAnimCurveNode. The input is an int index value parameter, a channel parameter ranging from 0, 1, and 2, representing the x, y, and z axes. The obtained animation curve FbxAnimCurve for a specific axis contains the animation frame data for that axis. FbxAnimCurveNode represents an animation curve node, and FbxAnimCurve contains the specific animation frame data. By obtaining FbxAnimCurve, keyframes of the animation can be edited. It should be noted that by default, indices 0, 1, and 2 correspond to the x, y, and z axes respectively, but this correspondence may not hold true due to different rotation order settings in FBX files. Therefore, when editing animation curves, it is necessary to correctly understand the relationship between the axis index and the actual axis.

[0040] The obtained FbxAnimCurve can be used to perform the following operations: for example, call the KeyGet(int pIndex) method based on the indices of the frames on the animation curve to get the FbxAnimCurveKey type of a specific frame; call the KeyAdd(FbxTime pTime) method to add a new animation frame at a specified time point; call the KeySet() method based on the indices of the frames on the animation curve to set the order, time point, and value of a specific frame by passing parameters; call the KeyRemove(int pIndex) method based on the indices of the frames on the animation curve to remove a specific frame; and call the KeyClear() method to clear all frames, but leave an empty FbxAnimCurve.

[0041] Step S300: After editing, the modified FBX file is exported as a new 3D model and animation file. FbxExporter and FbxIOSettings are created using FbxManager. FbxExporter is used to perform the file export operation, and FbxIOSettings is used to set export options. The Initialize() method of FbxExporter is called to initialize the export, and then the Export() method of FbxExporter is used to export the data in FbxScene to the specified path. Exporting the edited FBX file is to save the changes to disk for use in other tools or engines. The export process ensures that all edited animation data is correctly saved. All callback parts and import function return values ​​during the import process are checked. If all callback parts and import function return values ​​are true, the FBX file is successfully exported. Through the above steps, specific types of nodes can be traversed and edited for FBX files imported into Unity, and the edited data can be exported.

[0042] The technical solution of this application enables the reading and writing of FBX files within Unity. This means not only can FBX files be imported into Unity for use, but they can also be edited within Unity, and the modified results exported as new FBX files. This allows FBX to serve as an efficient medium for resource transfer, motion capture, and other functions within Unity. Developers can directly edit FBX files in detail within the Unity environment without frequently switching to other modeling software, reducing the time and complexity of switching between different tools and improving development efficiency. This two-way operation capability breaks the traditional one-way workflow, making FBX files more flexible and customizable in game development projects.

[0043] like Figure 2As shown, the second aspect of this application provides a Unity-based bidirectional operating system for 3D models and animation files, including an import module for importing FBX files via Unity scripts and importing the data of the FBX files into FbxScene. The process of importing FBX files includes creating an FbxManager, an FbxScene, FbxIOSettings, and an FbxImporter in the Unity script, and associating them with the FbxManager. The FbxImporter.Initialize() method is called, passing the local FBX file path and FbxIOSettings as parameters. The FbxImporter.Import() method is called to import the data of the FBX file into FbxScene. All callbacks and the return value of the import function are checked during the import process; if all callbacks and the import function return value are true, it indicates that the FBX file has been successfully imported into Unity.

[0044] The bidirectional operating system in this embodiment also includes an editing module, which is used to traverse the nodes of the FBX file in FbxScene to obtain nodes of different types, or to call the native methods of the FBX SDK to obtain nodes of a specified type from FbxScene and perform editing operations on the nodes. The editing process includes modifications to the 3D model structure, skinning, and animation. Modifications to the 3D model include the following: traversing to obtain all nodes FbxNode, calling the GetNodeAttribute() method on each node to obtain the node attribute FbxNodeAttribute, and then calling the GetAttributeType() method on each node attribute to obtain the node type. By determining whether a node is FbxNodeAttribute.EType.eMesh, Mesh components can be filtered out. If the node type is FbxNodeAttribute.EType.eMesh, then calling GetMesh() on FbxNode to obtain the FbxMesh, and then calling Dispose() on it, the Mesh component can be deleted. Removing Mesh components is to remove unnecessary geometric structures when editing FBX files, such as removing the model's mesh in motion capture data. Within this method, the GetChildCount() function is executed on all nodes to obtain the number of child nodes and the GetChild() function to obtain the child nodes. By using recursion, all Mesh components within the FBX can be deleted.

[0045] Furthermore, the process of traversing and editing the nodes of the FBX file in FbxScene also includes modifying the animation. The animation modification process includes: calling the GetGlobalSettings() method on FbxScene to obtain the global settings FbxGlobalSettings, and then setting or retrieving the animation's frame rate using the SetTimeMode() or GetTimeMode() methods of the global settings FbxGlobalSettings. Next, calling the GetCurrentAnimationStack() method on FbxScene to obtain the overall animation component FbxAnimStack, and then calling the SetName() method of the animation component FbxAnimStack to set the animation component's name. Finally, calling GetLocalTimeSpan() or SetLocalTimeSpan() on the animation component FbxAnimStack obtained in the aforementioned steps allows you to get or set the animation duration.

[0046] Furthermore, calling the `GetAnimLayerMember()` method on the animation component `FbxAnimStack` retrieves the animation layer. By sequentially calling `GetMember()`, `GetDstProperty()`, and `GetCurveNode()` methods through the `FbxAnimLayer` animation layer, we obtain `FbxObject`, `FbxProperty`, and `FbxAnimCurveNode` respectively. `GetMember()` requires an `int` type parameter for the index; by checking if the returned result is null and incrementing it from 0, we can achieve traversal. The animation curve node `FbxAnimCurveNode` contains all the animation curves for a given property. Obtaining the animation curve node is for further editing of the specific animation curve. Each `FbxAnimCurveNode` here corresponds to all the animation frames of a specific node in the animation, equivalent to the animation curve of an object within an `Animation` in Unity. We obtain the object `FbxObject` through the `GetFbxObject()` method of `GetDstProperty()`, then call the `GetName()` method of `FbxObject` to get the node name, ultimately obtaining the string-type node name.

[0047] Each animation curve node may contain animation curves along multiple axes, such as the x, y, and z axes. Obtaining the animation curve for a specific axis is for editing the specific animation data along that axis. Specifically, when performing detailed editing of animation curves in an FBX file, the animation curve FbxAnimCurve for a specific axis can be obtained by calling the GetCurve(int pChannelId) method of FbxAnimCurveNode. An int index value parameter, ranging from 0, 1, and 2, represents the x, y, and z axes. The obtained animation curve FbxAnimCurve for a specific axis contains the animation frame data for that axis. FbxAnimCurveNode represents an animation curve node, and FbxAnimCurve contains the specific animation frame data. By obtaining FbxAnimCurve, the keyframes of the animation can be edited.

[0048] The obtained FbxAnimCurve can be used to perform the following operations: for example, call the KeyGet(int pIndex) method based on the indices of the frames on the animation curve to get the FbxAnimCurveKey type of a specific frame; call the KeyAdd(FbxTime pTime) method to add a new animation frame at a specified time point; call the KeySet() method based on the indices of the frames on the animation curve to set the time point and value of a specific frame; call the KeyRemove(int pIndex) method based on the indices of the frames on the animation curve to remove a specific frame; and call the KeyClear() method to clear all frames, but leave an empty FbxAnimCurve.

[0049] The bidirectional operating system in this embodiment also includes an export module, which is used to export the modified FBX file as a new 3D model and animation file after editing is completed. FbxExporter and FbxIOSettings are created through FbxManager. FbxExporter is used to perform the file export operation, and FbxIOSettings is used to set export options. The Initialize() method of FbxExporter is called to initialize the export, and then the Export() method of FbxExporter is used to export the data in FbxScene to a specified path.

[0050] In summary, the technical solution of this application overcomes the problem that the one-way nature of Unity engine's FBX file processing in existing technologies has become a major obstacle to continuous development and resource sharing. The technical solution of this application enables free editing and modification of FBX files within Unity, meeting the diverse needs of game development and software production processes.

[0051] It should be understood that the specific process of each module performing the above-mentioned steps has been described in detail in the above method embodiments, and will not be repeated here for the sake of brevity.

[0052] A third aspect of this application provides a computer-readable storage medium storing a program for bidirectional manipulation of Unity-based 3D models and animation files, enabling the execution of the Unity-based bidirectional manipulation method for 3D models and animation files provided in the first aspect of this application. As will be understood by those skilled in the art, the aforementioned computer-readable storage medium allows embodiments implementing the above-described system and its unit functions to be implemented using hardware related to the computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When executed, the program performs embodiments including the above-described system and its unit functions. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, or optical discs.

[0053] A fourth aspect of this application provides an electronic device, comprising: at least one memory for storing a program; and at least one processor for executing the program stored in the memory. The electronic device may be a server. The electronic device includes a processor, a memory, a network interface, and a database connected via a system bus. The processor of the electronic device provides computing and control capabilities. The memory of the electronic device includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the electronic device is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the functions or steps of the Unity-based bidirectional operation method for 3D models and animation files described in this application.

[0054] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and substitutions can be made without departing from the technical principles of this application, and these improvements and substitutions should also be considered within the scope of protection of this application.

Claims

1. A method for bidirectional manipulation of 3D models and animation files based on Unity, characterized in that, include: Import the FBX file using a Unity script, and then import the data from the FBX file into FbxScene; Traverse the nodes of the FBX file in FbxScene to obtain nodes of different types, or call the native methods of the FBX SDK to obtain nodes of a specified type in FbxScene and perform editing operations on the nodes; The editing process includes modifications to the 3D model structure, skinning, and animation; The process of modifying the 3D model structure includes: Obtain the node attributes of the node to be processed; call the method to determine the node type on the node attributes to determine whether the node type is eMesh; if the node type is eMesh, obtain the Mesh object of the node and delete the corresponding Mesh component as needed; recursively process all child nodes; The process of modifying the animation includes: Get global settings or animation components, and modify the animation components in the FBX file. The animation components include the animation frame rate, animation duration, and animation layer. Get global settings by calling the GetGlobalSettings() method through FbxScene, and set or get the animation frame rate through the SetTimeMode() or GetTimeMode() methods of the global settings FbxGlobalSettings. Call GetLocalTimeSpan() or SetLocalTimeSpan() on the animation component to get or set the animation duration; get the animation layer by calling the GetAnimLayerMember() method on the animation component; Editing the animation curves in the animation layer includes adding, setting, and removing keyframes. Specifically, the `GetMember()`, `GetDstProperty()`, and `GetCurveNode()` methods are called sequentially on the animation layer to obtain the `FbxAnimCurveNode` of the animation curve. When editing the animation curve, the `GetCurve(int pChannelId)` method of `FbxAnimCurveNode` is called to obtain the animation curve `FbxAnimCurve` for a specific axis, inputting an `int` index value parameter. Based on the `FbxAnimCurve`, the keyframes of the animation are edited by performing the following operations: calling `KeyGet(int pIndex)` based on the `int` index of the frame on the animation curve to obtain the `FbxAnimCurveKey` of the specific frame; and calling `KeyAdd(FbxTime)`... pTime adds a new animation frame at a specified time point; KeySet() is called based on the int index of the frame on the passed animation curve to set the order, time point, and value of a specific frame; KeyRemove(int pIndex) is called based on the int index of the frame on the passed animation curve to remove a specific frame; KeyClear() is called to clear all frames, but leaves an empty FbxAnimCurve. After editing, export the modified FBX file as a new 3D model and animation file.

2. The method for bidirectional operation of 3D models and animation files based on Unity as described in claim 1, characterized in that, The importing of FBX files via Unity scripts includes: In the Unity script, create the interconnected FbxManager, FbxScene, FbxIOSettings, and FbxImporter in sequence; Initialize FbxImporter and use FbxImporter to import the data of the FBX file into FbxScene; Check all callbacks and import function return values ​​during the import process. If all callbacks and import function return values ​​are true, it means that the FBX file has been successfully imported into Unity.

3. The method for bidirectional operation of Unity-based 3D models and animation files as described in claim 1, characterized in that, The process of traversing the nodes of the FBX file in FbxScene to obtain different types of nodes includes: Obtain the root node of the imported FBX file; Starting from the root node, recursively traverse each node and its child nodes: get the number of child nodes; get the child node at the specified index; recursively call the traversal method until all nodes have been traversed.

4. The method for bidirectional operation of 3D models and animation files based on Unity as described in claim 1, characterized in that, The step of calling the native methods of the FBX SDK to obtain nodes of a specified type in FbxScene includes: obtaining global settings or animation components through native methods of the FBX SDK, and then obtaining the nodes of the specified type.

5. The method for bidirectional operation of 3D models and animation files based on Unity as described in claim 1, characterized in that, The step of exporting the modified FBX file as a new 3D model and animation file includes: In the Unity script, create the interconnected FbxManager, FbxExporter, and FbxIOSettings in sequence; Initialize FbxExporter and use FbxExporter to export the data of FbxScene to a newly created FBX file in the specified path; Check all callbacks and export function return values ​​during the export process. If all callbacks and export function return values ​​are true, it means that the FBX file has been successfully exported from Unity.

6. A bidirectional operating system for Unity-based 3D models and animation files, characterized in that, include: The import module is used to import FBX files into Unity and import the data of the FBX files into FbxScene; The editing module is used to traverse the nodes of the FBX file in FbxScene to obtain nodes of different types, or to call the native methods of the FBX SDK to obtain nodes of a specified type in FbxScene and perform editing operations on the nodes. The editing process includes modifications to the 3D model structure, skinning, and animation. The process of modifying the 3D model structure includes: Obtain the node attributes of the node to be processed; call the method to determine the node type on the node attributes to determine whether the node type is eMesh; if the node type is eMesh, obtain the Mesh object of the node and delete the corresponding Mesh component as needed; recursively process all child nodes; The process of modifying the animation includes: Get global settings or animation components, and modify the animation components in the FBX file. The animation components include the animation frame rate, animation duration, and animation layer. Get global settings by calling the GetGlobalSettings() method through FbxScene, and set or get the animation frame rate through the SetTimeMode() or GetTimeMode() methods of the global settings FbxGlobalSettings. Call GetLocalTimeSpan() or SetLocalTimeSpan() on the animation component to get or set the animation duration; get the animation layer by calling the GetAnimLayerMember() method on the animation component. Editing the animation curves in the animation layer includes adding, setting, and removing keyframes. Specifically, the `GetMember()`, `GetDstProperty()`, and `GetCurveNode()` methods are called sequentially on the animation layer to obtain the `FbxAnimCurveNode` of the animation curve. When editing the animation curve, the `GetCurve(int pChannelId)` method of `FbxAnimCurveNode` is called to obtain the animation curve `FbxAnimCurve` for a specific axis, inputting an `int` index value parameter. Based on the `FbxAnimCurve`, the keyframes of the animation are edited by performing the following operations: calling `KeyGet(int pIndex)` based on the `int` index of the frame on the animation curve to obtain the `FbxAnimCurveKey` of the specific frame; and calling `KeyAdd(FbxTime)`... pTime adds a new animation frame at a specified time point; KeySet() is called based on the int index of the frame on the passed animation curve to set the order, time point, and value of a specific frame; KeyRemove(int pIndex) is called based on the int index of the frame on the passed animation curve to remove a specific frame; KeyClear() is called to clear all frames, but leaves an empty FbxAnimCurve. The export module is used to export the modified FBX file as a new 3D model and animation file after editing is complete.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when run on a processor, causes the processor to perform the method as described in any one of claims 1 to 5.

8. An electronic device, characterized in that, include: At least one memory for storing programs; At least one processor is configured to execute a program stored in the memory, wherein when the program stored in the memory is executed, the processor is configured to perform the method as described in any one of claims 1 to 5.