Unity-based 3D model and animation file bidirectional operation method and related product
By importing, editing and exporting FBX files using the native methods of Unity scripts and FBX SDK in Unity, the problem of read-only restriction of FBX files in Unity is solved, and the deep editing and efficient development process of 3D models and animations is realized.
Patent Information
- Application Number
- CN202411650988.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-11-19
AI Technical Summary
The Unity game development engine has read-only restrictions when processing FBX files, and developers cannot deeply edit 3D models and animations in Unity, resulting in complex development processes and increased time costs.
Import FBX files through Unity scripts and use the native methods of the FBX SDK to traverse and edit nodes in the file, including modifications to 3D model structure, skinning and animations. After editing is completed, the modified FBX file is exported.
It realizes the ability to read and write FBX files in Unity, allowing developers to perform detailed FBX file editing in Unity environment, reducing the time and complexity of developers' conversion between different tools, and improving development efficiency.
Smart Images

Figure CN119540411A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computer animation production and editing, and in particular to a Unity-based 3D model and animation file bidirectional operation and related products. Background Art
[0002] As a unique file format of Autodesk, FBX files are widely used in the fields of modeling and game engines. It is a universal file format that integrates model and animation data. Due to its strong compatibility and rich data expression capabilities, FBX files have become an indispensable part of current game development and 3D modeling. Many well-known software and platforms support the import and export of FBX files, making this format play an important role in cross-platform and cross-software resource sharing and collaborative work.
[0003] However, in Unity, a popular game development engine, the processing of FBX files faces certain limitations. When an FBX file is imported into Unity, although it can automatically read and display the models, animations and other components in it, developers can only perform limited read-only operations on these components. Specifically, Unity's support for FBX files is mainly focused on the display and playback levels, while Unity cannot perform deeper editing and modification, such as animation editing, adding and removing model nodes, and deleting meshes.
[0004] This limitation has brought many inconveniences in the process of game development and software production. For example, during the development process, developers may need to adjust and optimize the models or animations in the FBX file according to actual needs, but Unity cannot directly provide these editing functions. This forces developers to return to the original modeling software to make modifications and then re-export the FBX file, which undoubtedly increases the complexity and time cost of the development process. In addition, with the growing demand for high-quality animations and complex models in game development, advanced technologies such as motion capture are also increasingly being used in game production. However, Unity's read-only restriction on FBX files has limited the application of these technologies on the Unity platform and prevented them from fully leveraging their advantages. Summary of the invention
[0005] The purpose of this application is to provide a Unity-based 3D model and animation file bidirectional operation and related products, which solves the problem that 3D models and animation files can only be read-only operated but cannot be edited in Unity.
[0006] In order to achieve the above objectives, this application adopts the following technical solutions:
[0007] A two-way operation method for 3D models and animation files based on Unity, comprising: importing an FBX file through a Unity script, and importing 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 the native method of the FBX SDK to obtain nodes of a specified type from FbxScene, and performing editing operations on the nodes; the editing process includes modifying the 3D model structure, skinning and animation; after the editing is completed, exporting the modified FBX file as a new 3D model and animation file.
[0008] In some embodiments, the importing of the FBX file through the Unity script includes: creating interconnected FbxManager, FbxScene, FbxIOSettings and FbxImporter in the Unity script in sequence; initializing FbxImporter, and using FbxImporter to import the data of the FBX file into FbxScene; checking all callback parts and import function return values in the import process, if all callback parts and import function return values are true, it means that the FBX file is successfully imported into Unity.
[0009] In some embodiments, traversing the nodes of the FBX file in the FbxScene to obtain different types of nodes includes: obtaining the root node of the imported FBX file; starting from the root node, recursively traversing each node and its child nodes: obtaining the number of child nodes; obtaining the child node of the specified index; recursively calling the traversal method until all nodes are traversed.
[0010] In some implementations, calling a native method of the FBX SDK to obtain a node of a specified type from the FbxScene includes: obtaining a global setting or an animation component through a native method of the FBX SDK, and then obtaining the node of the specified type.
[0011] In some embodiments, the editing operation on the node and the modification process of the 3D model structure include: obtaining the node attributes of the node to be processed; calling the method for determining the node type 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, deleting the corresponding Mesh component as needed; recursively processing all child nodes. Similarly, other types of nodes, such as model nodes, can also be deleted or edited.
[0012] In some embodiments, the node is edited, and the animation modification process includes: modifying the animation components in the FBX file, the animation components including the frame rate, animation duration and animation layer of the animation; editing the animation curve in the animation layer, including adding keyframes, setting keyframes and removing keyframes.
[0013] In some embodiments, exporting the modified FBX file as a new 3D model and animation file includes: creating interconnected FbxManager, FbxExporter and FbxIOSettings in Unity script in sequence; initializing FbxExporter, and 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 in the export process, if all callback parts and export function return values are true, it means that the FBX file is successfully exported from Unity.
[0014] The second aspect of the present application provides a Unity-based 3D model and animation file bidirectional operating system, including: an import module, which is used to import FBX files into Unity and import the data of the FBX file into FbxScene; an editing module, which is used to traverse the nodes of the FBX file in FbxScene to obtain different types of nodes, or call the native method of FBXSDK to obtain nodes of a specified type from FbxScene, and edit the nodes, and the editing process includes modifications to the 3D model structure, skinning and animation; an export module, which is used to export the modified FBX file as a new 3D model and animation file after the editing is completed.
[0015] A third aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program. When the computer program runs on a processor, the processor executes the method described in the first aspect.
[0016] The fourth aspect of the present application provides an electronic device, comprising: at least one memory for storing programs; and at least one processor for executing the programs stored in the memory. When the programs stored in the memory are executed, the processor is used to execute the method described in the first aspect.
[0017] Compared with the prior art, the present invention has the following advantages:
[0018] The present application provides a two-way operation of 3D models and animation files based on Unity and related products. The FBX file is imported through the Unity script, and different types of nodes of the FBX file are traversed or nodes of a specified type are obtained based on native methods and the nodes are edited. After the editing is completed, the modified FBX file is exported as a new 3D model and animation file. The technical solution of the present application can read and write FBX files in Unity, that is, it can not only import FBX files into Unity for use, but also edit the FBX file inside Unity, and export the modified result as a new FBX file, so that FBX can become an efficient medium for functions such as resource transfer and motion capture in Unity. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. 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 related drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 A schematic diagram of a flow chart of a method for bidirectionally operating a 3D model and an animation file based on Unity according to an embodiment of the present application is shown;
[0021] Figure 2 A schematic structural diagram of a Unity-based 3D model and animation file bidirectional operating system according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0022] The technical solutions of the specific implementation methods of the present application are further described in detail below in conjunction with the accompanying drawings. These implementation methods are only used to illustrate the present application, but not to limit the present application.
[0023] The term "and / or" in this application is a description of the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. In the present invention, the symbol " / " indicates that the associated objects are in an "or" relationship, for example, "A / B" means "A or B".
[0024] The terms "first" and "second" in the specification and claims of this application are used to distinguish different objects rather than to describe a specific order of the objects. For example, "first response message" and "second response message" are used to distinguish different response messages rather than to describe a specific order of the response messages.
[0025] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be considered as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0026] In the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more than two. For example, multiple processing units refer to two or more processing units, etc., and multiple elements refer to two or more elements, etc.
[0027] The following is a detailed description of a Unity-based 3D model and animation file bidirectional operation method and related products of the present application in conjunction with the accompanying drawings.
[0028] Figure 1 The following is a flow chart of a method for bidirectionally operating 3D models and animation files based on Unity according to an embodiment of the present application. Figure 1 As shown, the Unity-based bidirectional operation method of 3D models and animation files in the embodiment of the present application includes the following steps:
[0029] S100, import the FBX file through the Unity script, and import the data of the FBX file into the FbxScene. Specifically, install the Autodesk FBX SDK for Unity plug-in in the Unity Package Manager. After installing the plug-in, you can access and use many methods and interfaces originally provided in the native FBX SDK. The plug-in is adapted and integrated for Unity, making these methods and interfaces more adaptable and integrated in the Unity environment. Efficient. After installing the plug-in, call the FBXImport() method to import the FBX file. This step is a prerequisite for editing the 3D model. The FBX file needs to be loaded into the Unity environment for subsequent editing operations.
[0030] The process of importing FBX files includes creating FbxManager in the Unity script, as well as creating FbxScene, FbxIOSettings and FbxImporter, and associating them with FbxManager in turn when calling methods. Among them, FbxScene is used to store the data of FBX files, FbxIOSettings is used to set the import and export options, and FbxImporter is used to perform file import operations. During initialization, call the FbxImporter.Initialize() method, passing the local FBX file path, file format and FbxIOSettings as parameters. Call the FbxImporter.Import() method to import the data of the FBX file into the passed FbxScene. Check all callback parts and import function return values during the import process. If all callback parts and import function return values are true, it means that the FBX file is successfully imported through the Unity script.
[0031] Step S200, traverse the nodes of the FBX file in FbxScene to obtain nodes of different types, or call the native method of FBX SDK to obtain nodes of specified types from FbxScene, and perform editing operations on the nodes. The editing process includes modification of 3D model structure, skinning and animation. The native method of the aforementioned FBX SDK may be, for example, GetGlobalSettings() and GetCurrentAnimationStack(), and global settings or animation components are obtained through the native solution of FBX SDK to obtain nodes of specified types. 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, starting from the root node, recursively traversing each node and its child nodes. Obtain the number of child nodes through GetChildCount(), and use the GetChild() method to obtain the child node of the specified index, and recursively call the traversal method until all nodes are traversed. Traversing all nodes is to find the specific node that needs to be edited, for example, removing the Mesh component, and traversing to obtain all nodes FbxNode.
[0032] FbxNodeAttribute is a label attribute that each node has, which can be used to distinguish nodes. Call the GetNodeAttribute() method on the node to get the node attribute FbxNodeAttribute, and call the GetAttributeType() method on each node attribute to get the node type. By judging whether the node attribute is FbxNodeAttribute.EType.eMesh, you can filter out the Mesh component. If the node type is FbxNodeAttribute.EType.eMesh, call GetMesh() on FbxNode to get FbxMesh, and then call Dispose() on it to delete the Mesh component. The purpose of removing the Mesh component is to remove unnecessary geometric structures when editing FBX files, such as removing the Mesh of the model in motion capture data. In this method, perform GetChildCount() to get the number of child nodes and GetChild() to get the child nodes on all nodes. By using recursive operations, all Mesh components in FBX can be deleted. Similarly, other types of nodes can also be edited by name or category filtering, such as model bone nodes.
[0033] Furthermore, the process of importing nodes of FBX files in FbxScene and editing the nodes also includes modifying animations, including obtaining global settings or animation components through FBX SDK native methods, modifying animation components in FBX files, and the animation components include animation frame rate, animation duration and animation layers; editing animation curves in animation layers, including adding keyframes, setting keyframes and removing keyframes.
[0034] Specifically, you can call the GetGlobalSettings() method through FbxScene to get the global settings FbxGlobalSettings, which contains some basic information of the FBX file, such as the time mode (frame rate), which is crucial for subsequent animation editing operations. Knowing the current frame rate helps to maintain consistency when adding or modifying keyframes later. Set or get the frame rate of the animation through the SetTimeMode() or GetTimeMode() method of the global settings FbxGlobalSettings. The return parameter obtained in this process and the call parameter set must be the enumeration type of FbxTime.EMode, including the commonly used 24, 30, 60, 100 and 120 frames, as well as special 72, 96, 1000 frames, etc.
[0035] Call the GetCurrentAnimationStack() method on FbxScene to get the overall animation component FbxAnimStack, and call the SetName() method of the animation component FbxAnimStack to set the name of the animation component. The animation component is the main structure for storing animation data in the FBX file. Getting the animation component is the prerequisite for editing animations. All animation layers and animation curves belong to a certain animation component. Setting the name of the animation component helps to manage and distinguish multiple animation components. In actual projects, naming the animation components can improve readability and maintainability.
[0036] Calling GetLocalTimeSpan() or SetLocalTimeSpan() on the animation component FbxAnimStack can get or set the animation duration. The animation duration defines the start time and the number of sections of the animation. Getting and setting the animation duration helps ensure that the animation plays within the correct time range. The FbxTime.FromTime() method can be used to create a time period FbxTimeSpan that is more detailed than the Frame level.
[0037] Calling the GetAnimLayerMember() method on the animation component FbxAnimStack can obtain the animation layer, which is similar to the Layer in the Animation Controller in Unity. It is used to organize and manage different animation data. Obtaining the animation layer is the prerequisite for editing specific animation curves. Calling the GetMember(), GetDstProperty(), and GetCurveNode() methods in sequence through the FbxAnimLayer animation layer to obtain FbxObject, FbxProperty, and FbxAnimCurveNode in sequence. Among them, GetMember() needs to pass the int type parameter of the index. By judging whether the returned result is Null, the traversal can be realized by gradually increasing from 0. Obtaining the animation curve node is to further edit the specific animation curve. Each FbxAnimCurveNode here corresponds to all the animation frames of a node in the animation, which is equivalent to the animation curve of a certain object node in the Animation in Unity. Get the object FbxObject through the GetFbxObject() method of GetDstProperty(), then call the GetName() method of FbxObject to get the node name, and finally get the node name of string type.
[0038] Calling the GetName() method of FbxAnimCurveNode gets the definition name of the animation curve type in the FBX file. For example, the three common ones are T, R, and S, which represent the operation of the component corresponding to Translation, Rotation, and Scale. When editing animations, sometimes you need to remove some unnecessary animation curves. For example, when the characteristic transformation of a model no longer requires animation control, you can directly delete the entire animation curve and execute the Dispose() method on FbxAnimCurveNode.
[0039] Each animation curve node may contain animation curves for multiple axes, such as the x-axis, y-axis, and z-axis. The purpose of obtaining the animation curve for a specific axis is to edit the specific animation data for that axis. Specifically, when editing the animation curve in the FBX file in detail, you can obtain the animation curve FbxAnimCurve for a specific axis by calling the GetCurve(int pChannelId) method of FbxAnimCurveNode. By inputting the int index value parameter, the channel parameter in the range of 0, 1, and 2 represents the three axes of x, y, and z. The obtained animation curve FbxAnimCurve for a specific axis contains the animation frame data on the corresponding axis. FbxAnimCurveNode represents an animation curve node, and FbxAnimCurve contains specific animation frame data. By obtaining FbxAnimCurve, you can edit the keyframes of the animation. It should be noted that by default, indexes 0, 1, and 2 correspond to the x, y, and z axes respectively, but since the FBX file may have different rotation order settings, this correspondence may not hold. Therefore, when editing animation curves, you need to correctly understand the relationship between the axis index and the actual axis.
[0040] The following operations can be performed on the obtained FbxAnimCurve, for example, calling the KeyGet(int pIndex) method according to the int type sequence index of the frame on the animation curve passed in to obtain the FbxAnimCurveKey type of a specific frame; calling the KeyAdd(FbxTime pTime) method to add a new animation frame at the specified time point; calling the KeySet() method according to the int type sequence index of the frame on the animation curve passed in to set the order, time point and value of the specific frame by passing parameters; calling the KeyRemove(int pIndex) method according to the int type sequence index of the frame on the animation curve passed in to remove the specific frame; calling the KeyClear() method to clear all frames, but keep the empty FbxAnimCurve.
[0041] Step S300, after editing is completed, the modified FBX file is exported as a new 3D model and animation file. FbxExporter and FbxIOSettings are created through FbxManager. FbxExporter is used to perform the file export operation, and FbxIOSettings is used to set the export options. The Initialize() method of FbxExporter is called to initialize the export, and then the data in FbxScene is exported to the specified path through the Export() method of FbxExporter. The purpose of 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 saved correctly. Check all callback parts and import function return values in the import process. If all callback parts and import function return values are true, it means that the FBX file is successfully exported. Through the above steps, specific types of nodes can be traversed and edited for the FBX file imported in Unity, and the edited data can be exported.
[0042] The technical solution of the present application is capable of reading and writing FBX files in Unity, that is, not only can the FBX file be imported into Unity for use, but the FBX file can also be edited inside Unity, and the modified result can be exported as a new FBX file, so that FBX can become an efficient medium for functions such as resource transfer and motion capture in Unity. Developers can directly edit FBX files in detail in the Unity environment without having to frequently switch 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 process, making FBX files more flexible and customizable in game development projects.
[0043] like Figure 2As shown, the second aspect of the present application provides a bidirectional operating system for 3D models and animation files based on Unity, which includes an import module, which is used to import FBX files through Unity scripts and import the data of FBX files into FbxScene. The process of importing FBX files includes creating FbxManager in the Unity script, creating FbxScene, FbxIOSettings and FbxImporter, and associating them with FbxManager. Use the FbxImporter.Initialize() method, passing the local FBX file path and FbxIOSettings as parameters. Call the FbxImporter.Import() method to import the data of the FBX file into FbxScene. Check all callback parts and import function return values in the import process. If all callback parts and import function return values are true, it means that the FBX file is successfully imported into Unity.
[0044] The bidirectional operating system of the embodiment of the present application also includes an editing module, which is used to traverse the nodes of the FBX file in FbxScene to obtain different types of nodes, or call the native method of the FBX SDK to obtain the nodes of the specified type from FbxScene, and perform editing operations on the nodes; the editing process includes the modification of the 3D model structure, skinning and animation; wherein, the modification of the 3D model includes the following: traverse all nodes FbxNode, call the GetNodeAttribute() method on the node to obtain the node attribute FbxNodeAttribute, and call the GetAttributeType() method for each node attribute to obtain the node type. By determining whether the node is FbxNodeAttribute.EType.eMesh, the Mesh component can be filtered out. If the node type is FbxNodeAttribute.EType.eMesh, the FbxMesh is obtained by calling GetMesh() through FbxNode, and then calling Dispose() on it to complete the deletion of the Mesh component. The purpose of removing the Mesh component is to remove unnecessary geometric structures when editing FBX files, such as removing the Mesh of the model in motion capture data. In this method, execute GetChildCount() to obtain the number of child nodes and GetChild() to obtain child nodes for all nodes. By using recursive operations, all Mesh components in FBX can be deleted.
[0045] Furthermore, the process of traversing the nodes of the FBX file in FbxScene and editing the nodes also includes the modification of the animation. The process of modifying the animation includes: calling the GetGlobalSettings() method based on FbxScene to obtain the global settings FbxGlobalSettings, and setting or getting the frame rate of the animation through the SetTimeMode() or GetTimeMode() method of the global settings FbxGlobalSettings. Next, calling the GetCurrentAnimationStack() method on FbxScene to obtain the overall animation component FbxAnimStack, and calling the SetName() method of the animation component FbxAnimStack to set the name of the animation component. Calling GetLocalTimeSpan() or SetLocalTimeSpan() based on the animation component FbxAnimStack obtained in the above steps can obtain or set the animation duration.
[0046] Furthermore, calling the GetAnimLayerMember() method on the animation component FbxAnimStack can obtain the animation layer, and calling the GetMember(), GetDstProperty(), and GetCurveNode() methods in sequence through the FbxAnimLayer animation layer to obtain FbxObject, FbxProperty, and FbxAnimCurveNode in sequence. Among them, GetMember() needs to pass the int type parameter of the index. By judging whether the return result is Null, the traversal can be realized by gradually increasing from 0. The animation curve node FbxAnimCurveNode contains all the animation curves of a property. The purpose of obtaining the animation curve node is to further edit the specific animation curve. Each FbxAnimCurveNode here corresponds to all the animation frames of a node in the animation, which is equivalent to the animation curve of an object in the Animation in Unity. Get the object FbxObject through the GetFbxObject() method of GetDstProperty(), and then call the GetName() method of FbxObject to obtain the node name, and finally obtain the node name of string type.
[0047] Each animation curve node may contain animation curves for multiple axes, such as the x-axis, y-axis, and z-axis. Obtaining the animation curve for a specific axis is to edit the specific animation data of that axis. Specifically, when editing the animation curve in the FBX file in detail, you can obtain the animation curve FbxAnimCurve for a specific axis by calling the GetCurve(int pChannelId) method of FbxAnimCurveNode. By inputting an int index value parameter, the channel parameter in the range of 0, 1, and 2 represents the three axes of x, y, and z. The obtained animation curve FbxAnimCurve for a specific axis contains the animation frame data on the corresponding axis. FbxAnimCurveNode represents an animation curve node, and FbxAnimCurve contains specific animation frame data. By obtaining FbxAnimCurve, you can edit the key frames of the animation.
[0048] The following operations can be performed on the obtained FbxAnimCurve, for example, calling the KeyGet(int pIndex) method according to the int type sequence index of the frame on the animation curve passed in to obtain the FbxAnimCurveKey type of a specific frame; calling the KeyAdd(FbxTime pTime) method to add a new animation frame at the specified time point; calling the KeySet() method according to the int type sequence index of the frame on the animation curve passed in to set the time point and value of the specific frame; calling the KeyRemove(int pIndex) method according to the int type sequence index of the frame on the animation curve passed in to remove the specific frame; calling the KeyClear() method to clear all frames, but keep the empty FbxAnimCurve.
[0049] The bidirectional operating system of the embodiment of the present application also includes an export module, which is used to export the modified FBX file as a new 3D model and animation file after the 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 the 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.
[0050] In summary, the technical solution of the present application overcomes the problem that the unidirectional nature of the prior art Unity engine in FBX file processing has become a major obstacle to continued development and resource sharing. The technical solution of the present application can implement a solution for free editing and modification of FBX files in Unity, meeting the diverse needs in the process of game development and software production.
[0051] It should be understood that the specific process of each module executing the above corresponding steps has been described in detail in the above method embodiment, and for the sake of brevity, it will not be repeated here.
[0052] The third aspect of the present application provides a computer-readable storage medium, on which a program of a two-way operation method for 3D models and animation files based on Unity is stored, so that the two-way operation method for 3D models and animation files based on Unity provided in the first aspect of the present application is executed. As for the aforementioned computer-readable storage medium, those skilled in the art can understand that the implementation method of the above-mentioned system and the functions of each unit can be completed by hardware related to the computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When the program is executed, it executes the implementation method including the above-mentioned system and the functions of each unit. The aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM or optical disk.
[0053] The fourth aspect of the present application provides an electronic device, comprising: at least one memory for storing programs; at least one processor for executing the programs stored in the memory. The electronic device may be a server. The electronic device comprises a processor, a memory, a network interface and a database connected via a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device comprises a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, the functions or steps of the bidirectional operation method of 3D models and animation files based on Unity of the present application are implemented.
[0054] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and substitutions can be made without departing from the technical principles of the present application. These improvements and substitutions should also be regarded as the scope of protection of the present application.
Claims
1. A two-way operation method for 3D models and animation files based on Unity, characterized in that: include: Import the FBX file through the Unity script, and import the data of the FBX file into FbxScene; Traverse the nodes of the FBX file in FbxScene to obtain nodes of different types, or call the native method of FBX SDK to obtain nodes of specified types from FbxScene, and perform editing operations on the nodes; the editing process includes modifying the 3D model structure, skinning and animation; After editing is complete, 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 claimed in claim 1, characterized in that: Importing FBX files through 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 callback parts and import function return values during the import process. If all callback parts and import function return values are true, it means that the FBX file is successfully imported into Unity.
3. The method for bidirectional operation of 3D models and animation files based on Unity as claimed in claim 1, characterized in that: The nodes of the FBX file in FbxScene are traversed to obtain different types of nodes, including: Get the root node of the imported FBX file; Starting from the root node, recursively traverse each node and its child nodes: obtain the number of child nodes; obtain the child node of the specified index; recursively call the traversal method until all nodes are traversed.
4. The method for bidirectional operation of 3D models and animation files based on Unity as claimed in claim 1, characterized in that: The calling of the native method of the FBX SDK to obtain the node of the specified type from the FbxScene includes: obtaining the global setting or animation component through the native method of the FBX SDK, and then obtaining the node of the specified type.
5. The method for bidirectional operation of 3D models and animation files based on Unity as claimed in claim 3 or 4, characterized in that: The node is edited, and the process of modifying the 3D model structure includes: Get the node attributes of the node that needs to be processed; Calling a method for determining the node type on the node attribute 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.
6. The method for bidirectional operation of 3D models and animation files based on Unity as claimed in claim 1, characterized in that: The node is edited, and the animation modification process includes: Modify the animation components in the FBX file, wherein the animation components include the frame rate, animation duration and animation layer of the animation; The animation curve in the animation layer is edited, including adding keyframes, setting keyframes, and removing keyframes.
7. The method for bidirectional operation of 3D models and animation files based on Unity as claimed 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 the FbxScene to a newly created FBX file in a specified path; Check all callback parts and export function return values in the export process. If all callback parts and export function return values are true, it means that the FBX file is successfully exported from Unity.
8. A two-way operating system for 3D models and animation files based on Unity, characterized in that: include: An import module, which is used to import FBX files into Unity and import the data of the FBX files into FbxScene; An editing module, which is used to traverse the nodes of the FBX file in FbxScene to obtain nodes of different types, or call the native method of the FBX SDK to obtain nodes of a specified type from FbxScene, and perform editing operations on the nodes. The editing process includes modification of the 3D model structure, skinning and animation; The export module is used to export the modified FBX file as a new 3D model and animation file after the editing is completed.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed on a processor, the processor is caused to execute the method according to any one of claims 1 to 7.
10. An electronic device, characterized in that: include: at least one memory for storing a program; At least one processor is used to execute the program stored in the memory, and when the program stored in the memory is executed, the processor is used to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Large-scale digital workshop three-dimensional model cross-platform consistency method based on Unity platform
CN114155341A
Method, device and system for generating skinned skeleton animation and method, device and system for editing skinned skeleton animation
CN116416348A
Animation file compression method, terminal equipment and computer readable storage medium
CN116594969A
Method for simplifying low modulus from high modulus and automatically mapping UV texture
CN117274481A
System and method for diagnosing battery
KR1020240170756A