Equipment model rendering method and device, computer device and storage medium
By setting the bone matrix index of the target bone and the array of loaded bones of the game character in the 3D game, the memory waste caused by the discontinuous bone IDs of the game character is solved, and more efficient memory usage is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING PIXEL SOFTWARE TECH
- Filing Date
- 2022-12-12
- Publication Date
- 2026-04-17
AI Technical Summary
In 3D games, the bone IDs of equipment loaded onto game characters are not continuous, leading to a waste of memory resources. Existing technologies store the bone matrix according to the largest ID when generating the array, which also causes memory waste.
The system optimizes array storage by setting a first array to store the bone matrix index of the target bone, a second array to store the bone matrix of the loaded bones of the game character, reading the bone matrix from the second array according to the target bone ID for rendering, and updating the mapping table.
This avoids wasting memory resources due to discontinuous skeletal IDs of game characters and improves memory utilization efficiency.
Smart Images

Figure CN116020112B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically, to a method, apparatus, computer device, and storage medium for rendering equipment models. Background Technology
[0002] In 3D games, each game character may wear different equipment, such as antennae on their head, a cape on their back, and a pendant on their waist. The models of these equipment will change along with the skeletal animation of the game character, thus producing animation effects.
[0003] A game character's skeleton includes the basic skeleton used to control the character's body, as well as many additional bones used to control the equipment the character wears. If all the bones are pre-loaded onto the character, many unused additional bones will be calculated during skeletal animation, affecting efficiency. Therefore, the common practice is to dynamically load additional bones, that is, load the bones required for a specific piece of equipment only when it is worn. This also means that the IDs of the bones loaded onto the game character are often not consecutive.
[0004] When rendering equipment models, it is necessary to obtain the offset data of the bone matrix of the corresponding bone based on the bone ID. Currently, the common practice is to generate an array according to the maximum ID of the bones of the game character, and then store the bone matrix of each bone in the array at the position with the same order as the ID of that bone. Since the IDs of the bones loaded on the game character are not consecutive, there will be many empty positions in the array, resulting in a waste of memory resources. Summary of the Invention
[0005] To overcome the shortcomings of the prior art, embodiments of the present invention provide an equipment model rendering method, apparatus, computer device, and storage medium.
[0006] The technical solution of this invention can be implemented as follows:
[0007] In a first aspect, the present invention provides a method for rendering an equipment model, the method comprising:
[0008] Based on the ID of each target bone used to control the equipment model to be rendered and the first array corresponding to the equipment model to be rendered, the bone matrix of each target bone is read from the second array corresponding to the game character;
[0009] Each of the target bones is loaded by the game character when the equipment model to be rendered is created. The first array stores the bone matrix index of each target bone, and the second array stores the bone matrix of each loaded bone of the game character. The bone matrix index represents the storage position of the bone matrix in the second array.
[0010] The equipment model to be rendered is rendered based on the bone matrix of each target bone.
[0011] Optionally, before reading the bone matrix of each target bone from the second array corresponding to the game character based on the ID of each target bone used to control the equipment model to be rendered and the first array corresponding to the equipment model to be rendered, the method further includes:
[0012] When creating the equipment model to be rendered, the mapping table corresponding to the game character at the current moment is updated based on the ID of each target bone to obtain the updated mapping table;
[0013] The mapping table stores multiple mapping information entries, each of which includes the ID of a loaded bone of the game character and a bone matrix index.
[0014] Based on the ID of each target bone, the bone matrix index of each target bone is obtained from the updated mapping table to generate the first array.
[0015] Optionally, the step of updating the mapping table corresponding to the game character at the current moment based on the ID of each target bone includes:
[0016] Based on the ID of each target bone and the mapping table, the bone to be processed is determined. The bone to be processed is the target bone that has not been loaded by the game character at the current moment.
[0017] By loading the bone to be processed, a bone matrix of the bone to be processed is generated;
[0018] The bone matrix of the bone to be processed is stored in the second array, and the bone matrix index of the bone to be processed is generated according to the storage position of the bone matrix of the bone to be processed in the second array.
[0019] The mapping information, which includes the ID of the bone to be processed and the bone matrix index, is added to the mapping table to update the mapping table.
[0020] Optionally, the step of determining the bone to be processed based on the ID of each target bone and the mapping table includes:
[0021] For each target bone, if there is no mapping information including the ID of the target bone in the mapping table, then the target bone is used as the bone to be processed.
[0022] Optionally, the method further includes:
[0023] If the game character has a deleted equipment model, the mapping table at the current moment is updated according to the label of each target bone used to control the deleted equipment model, so as to obtain the updated mapping table.
[0024] Using the updated mapping table, the first array corresponding to the undeletable equipment models of the game character is updated.
[0025] Optionally, the step of updating the mapping table at the current moment based on the label used to control each target bone of the deleted equipment model includes:
[0026] Based on the label of each target bone, determine the bones to be unloaded from all the target bones;
[0027] Remove the mapping information, including the ID of the bone to be unloaded, from the mapping table;
[0028] According to the bone matrix index of the bone to be unloaded, the bone matrix of the bone to be unloaded is deleted from the second array, and the storage position of each bone matrix that has not been deleted in the second array is adjusted to obtain the updated second array;
[0029] The mapping table is updated using the updated second array.
[0030] Optionally, the step of determining the bone to be unloaded based on the label of each target bone includes:
[0031] For each target bone, if it is determined, based on the target bone's label, that the target bone is not a base bone of the game character, then the target bone is designated as a bone to be unloaded.
[0032] Secondly, embodiments of the present invention provide an equipment model rendering apparatus, the apparatus comprising:
[0033] The acquisition module is used to read the bone matrix of each target bone from the second array of the game character based on the ID of each target bone used to control the equipment model to be rendered and the first array corresponding to the equipment model to be rendered;
[0034] Each of the target bones is loaded by the game character when the equipment model to be rendered is created. The first array stores the index of the bone matrix of each target bone, and the second array stores the bone matrix of each loaded bone of the game character. The index of the bone matrix represents the storage position of the bone matrix in the second array.
[0035] The rendering module is used to render the equipment model to be rendered based on the bone matrix of each target bone.
[0036] Thirdly, embodiments of the present invention provide a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the equipment model rendering method as described in the first aspect above.
[0037] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the equipment model rendering method described in the first aspect above.
[0038] Compared to existing technologies, the equipment model rendering method provided in this embodiment of the invention firstly reads the bone matrix of each target bone from a second array corresponding to the game character, based on the ID of each target bone used to control the equipment model to be rendered and a first array corresponding to the equipment model to be rendered. Each target bone is loaded by the game character when the equipment model to be rendered is created. The first array stores the bone matrix index of each target bone, and the second array stores the bone matrix of each loaded bone of the game character. The bone matrix index represents the storage position of the bone matrix in the second array. Then, the equipment model to be rendered is rendered based on the bone matrix of each target bone. Because this embodiment of the invention sets a first array for the equipment model to be rendered and a second array for the game character, storing the bone matrix of each recorded bone of the game character in the second array, and storing the bone matrix index representing the storage position of the bone matrix in the second array, it avoids the waste of memory resources caused by generating an array for storing bone matrices based on the maximum ID of the game character's bones. Attached Figure Description
[0039] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 A flowchart illustrating an equipment model rendering method provided in an embodiment of the present invention;
[0041] Figure 2 A flowchart illustrating a first array generation method provided in an embodiment of the present invention;
[0042] Figure 3 A flowchart illustrating a first array update method provided in an embodiment of the present invention;
[0043] Figure 4 A functional unit block diagram of an equipment model rendering device provided in an embodiment of the present invention;
[0044] Figure 5 This is a schematic block diagram of a computer device provided in an embodiment of the present invention.
[0045] Icons: 100 - Equipment model rendering device; 101 - Acquisition module; 102 - Rendering module; 103 - Generation module; 104 - Update module; 200 - Computer equipment; 210 - Memory; 220 - Processor. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0047] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0048] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0049] Furthermore, the terms "first" and "second" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.
[0050] It should be noted that, where there is no conflict, the features in the embodiments of the present invention can be combined with each other.
[0051] To reduce the waste of memory resources, this invention provides a method for rendering equipment models, which will be described in detail below.
[0052] Please refer to Figure 1 The equipment model rendering method includes steps S101 to S102.
[0053] S101, based on the ID of each target bone used to control the equipment model to be rendered and the first array corresponding to the equipment model to be rendered, read the bone matrix of each target bone from the second array corresponding to the game character.
[0054] Each target bone is loaded by the game character when the equipment model to be rendered is created. The first array stores the bone matrix index of each target bone, and the second array stores the bone matrix of each loaded bone of the game character. The bone matrix index represents the storage position of the bone matrix in the second array.
[0055] The number of elements in the first array is equal to the number of target bones. For example, assuming the equipment model to be rendered is controlled by 5 target bones, then the number of elements in the first array corresponding to the equipment model to be rendered is 5, and each element stores the bone matrix index of a target bone.
[0056] The number of elements in the second array is equal to the number of loaded bones. For example, assuming that the game character has 42 loaded bones, then the number of elements in the second array corresponding to the game character is 42, and each element stores a bone matrix of a loaded bone.
[0057] Understandably, when the number of loaded bones of a game character changes, the number of elements in the second array corresponding to the game character also changes accordingly.
[0058] S102 renders the equipment model to be rendered based on the bone matrix of each target bone.
[0059] The skeleton matrix consists of the bone's displacement, rotation, and scaling information. Displacement information includes the bone's position in a defined coordinate system. Rotation information includes the bone's rotation angle around each coordinate axis in the defined coordinate system. Scaling information includes the bone's scaling in each direction within the defined coordinate system.
[0060] The vertex coordinates of the equipment model to be rendered are calculated using the offset data of the skeletal matrix, and then the equipment model is rendered according to the vertex coordinates to achieve the animation effect.
[0061] The first array corresponding to the equipment model to be rendered needs to be generated when the equipment model is created. Please refer to [the relevant documentation]. Figure 2 Before executing step S101, the following steps S201 to S202 must be executed first to generate the first array corresponding to the equipment model to be rendered.
[0062] S201, when creating the equipment model to be rendered, the mapping table corresponding to the game character at the current moment is updated based on the ID of each target bone to obtain the updated mapping table.
[0063] The mapping table stores multiple mapping records. Each mapping record includes the ID of a loaded skeleton of a game character and the skeleton matrix index.
[0064] As one possible implementation, the mapping table can be a map.
[0065] In this embodiment of the invention, the bone matrix indices of each target bone stored in the first array corresponding to the equipment model to be rendered are obtained from the mapping table. Since the target bones used to control the equipment model to be rendered may have been loaded by the game character or may not have been loaded by the game character, and the mapping table currently stores the bone IDs and bone matrix indices that were loaded by the game character before the equipment model to be rendered is created, when creating the equipment model to be rendered, it is necessary to first update the mapping table by loading the target bones that have not been loaded by the game character, and then use the updated mapping table to generate the first array corresponding to the equipment model to be rendered.
[0066] Optionally, step S201 may include sub-steps S201-1 to S201-4.
[0067] S201-1, Based on the ID and mapping table of each target bone, determine the bone to be processed.
[0068] Among them, the bones to be processed are the target bones that have not been loaded by the game character at the current moment.
[0069] The implementation process of step S201-1 can be as follows:
[0070] For each target bone, if there is no mapping information including the ID of the target bone in the mapping relationship table, the target bone is determined to be a bone to be processed.
[0071] Understandably, if the mapping table contains mapping information including the ID of the target bone, then the target bone will not be treated as a bone to be processed.
[0072] For example, suppose there are 5 target bones used to control the rig model to be rendered, with IDs 2, 8, 11, 15, and 33. Since there is no mapping information including IDs 2 and 15 in the mapping table when the rig model is created, the bones with IDs 2 and 15 are used as the bones to be processed.
[0073] Since the mapping table contains mapping information including IDs 8, 11, and 33, the bone matrix index of the bones with IDs 8, 11, and 33 can be directly extracted from the corresponding mapping information.
[0074] S201-2 generates a bone matrix of the bones to be processed by loading the bones to be processed.
[0075] When loading the bones to be processed is complete, a bone matrix of the bones to be processed in the coordinate system of the current game scene is generated.
[0076] S201-3, store the bone matrix of the bone to be processed into the second array, and generate the bone matrix index of the bone to be processed according to the storage position of the bone matrix of the bone to be processed in the second array.
[0077] Understandably, before storing the bone matrix of the bones to be processed into the second array, the second array needs to be expanded.
[0078] For example, suppose that among the five target bones used to control the equipment model to be rendered, the target bones with IDs 2 and 15 are the bones to be processed, that is, the bones of the game character that have not been loaded.
[0079] At the current moment, the second array contains 42 elements of a bone matrix used to store the 42 loaded bones of the game character. Since the game character has newly loaded bones with IDs 2 and 15, the capacity of the second array needs to be expanded from 42 elements to 44 elements.
[0080] After expanding the second array, the bone matrices of bones with IDs 2 and 15 are stored in the 43rd and 44th elements of the second array, respectively.
[0081] S201-4, add the mapping information containing the ID of the bone to be processed and the bone matrix index into the mapping relationship table to update the mapping relationship table.
[0082] For example, assuming the bone matrix of the bones to be processed with IDs 2 and 15 is stored in the 43rd to 44th elements of the second array, the address of the 43rd to 44th elements of the second array can be used as the index of the bone matrix of the bones to be processed with IDs 2 and 15, and two new mapping information can be generated. Then, the two new mapping information can be added to the mapping relationship table.
[0083] S202, based on the ID of each target bone, obtain the bone matrix index of each target bone from the updated mapping table to generate the first array.
[0084] For example, assuming there are 5 target bones used to control the equipment model to be rendered, the mapping information containing the ID of each target bone is obtained from the updated mapping table according to the ID of each of the 5 target bones. Then, the bone matrix index in each obtained mapping information is extracted and stored in the 5 elements of the first array corresponding to the equipment model to be rendered.
[0085] When an equipment model is removed from a game character, the character needs to unload the bones used to control the removed equipment model. The elements of the bone matrix in the second array that store these removed bones will be cleared. To avoid wasting memory resources, the size of the second array needs to be reduced, which may cause changes to the bone matrix index of the game character's unloaded bones.
[0086] To ensure that the remaining equipment models on the game character can be rendered correctly, the first array corresponding to the remaining equipment models needs to be updated.
[0087] Please refer to Figure 3 The process of updating the first array corresponding to the equipment model to be rendered can be as follows:
[0088] S301, if the game character has a deleted equipment model, then update the mapping table at the current moment according to the label of each target bone used to control the deleted equipment model, and obtain the updated mapping table.
[0089] As one possible implementation, step S301 may include sub-steps S301-1 to S301-4:
[0090] S301-1, Based on the label of each target bone, identify the bones to be unloaded from all target bones.
[0091] The skeleton of a game character includes a base skeleton for controlling the character's body, as well as many additional bones. Each bone is labeled as either a base bone or an additional bone when it is loaded.
[0092] Optionally, step S301-1 can be implemented as follows:
[0093] For each target bone, if it is determined from the target bone's label that the target bone is not a base bone of the game character, then the target bone is designated as a bone to be unloaded.
[0094] Understandably, if the target bone is determined to be the base bone of the game character based on its label, then the target bone cannot be used as a bone to be unloaded.
[0095] In other words, the additional bones used to control the target skeleton of the deleted equipment model need to be unloaded.
[0096] For example, suppose there are 5 target bones used to control the deleted equipment model, with IDs 2, 8, 11, 15 and 33. Among them, the target bones with IDs 8 and 11 are labeled as base bones, while the target bones with IDs 2, 15 and 33 are labeled as additional bones. Therefore, the target bones with IDs 2, 15 and 33 should be used as the bones to be unloaded.
[0097] S301-2, The mapping information including the ID of the skeleton to be unloaded is deleted from the mapping relationship table.
[0098] For example, suppose that among the target bones used to control the deleted equipment model, the target bones with IDs 2, 15 and 33 are bones to be unloaded. Before unloading them, the three mapping information entries with IDs 2, 15 and 33 in the mapping relationship table must be deleted.
[0099] S301-3, according to the bone matrix index of the bone to be unloaded, delete the bone matrix of the bone to be unloaded from the second array, and adjust the storage position of each bone matrix that has not been deleted in the second array to obtain the updated second array.
[0100] For example, suppose that among the target bones used to control the deleted equipment model, the target bones with IDs 2, 15 and 33 are the bones to be unloaded, and the second array includes 42 elements, wherein the 2nd, 10th and 16th elements are used to store the bone matrix of the target bones with IDs 2, 15 and 33, respectively.
[0101] Since the game character needs to unload 3 bones, the number of elements in the second array needs to be reduced by 3. That is, after clearing the 2nd, 10th and 16th elements in the second array, the bone matrix originally stored in the 3rd to 9th elements is moved to the 2nd to 8th elements, the bone matrix originally stored in the 11th to 15th elements is moved to the 9th to 13th elements, and the original 16th to 42nd elements is moved to the 14th to 39th elements.
[0102] S301-4, Update the mapping table using the updated second array.
[0103] In this embodiment of the invention, the implementation process of steps S301-4 can be as follows:
[0104] First, obtain the update log of the second array. The update log records the address of the element in each skeleton matrix before migration and the address of the element in the skeleton matrix after migration.
[0105] Then, based on the bone matrix index of each bone included in the mapping information in the mapping relationship table, the address of the element of the bone matrix before migration is determined;
[0106] Next, the addresses of the elements in the skeleton matrix before migration are retrieved from the update log to determine the addresses of the elements in the skeleton matrix after migration.
[0107] Finally, based on the addresses of the elements in the migrated bone matrix, a new bone matrix index is generated to replace the original bone matrix index in the corresponding mapping information.
[0108] S302, using the updated mapping table, update the first array corresponding to the equipment models of the game characters that have not been deleted.
[0109] For example, assuming there are 5 target bones used to control the equipment model that has not been deleted, the mapping information containing the ID of each target bone is obtained from the updated mapping table according to the ID of each of the 5 target bones. Then, the bone matrix index in each obtained mapping information is extracted and used to replace the 5 elements of the first array corresponding to the equipment model that has not been deleted.
[0110] In order to perform the corresponding steps in the above method embodiments and various possible implementations, an implementation of the equipment model rendering device 100 is given below.
[0111] Please refer to Figure 4 The equipment rendering device 100 includes an acquisition module 101, a rendering module 102, a generation module 103, and an update module 104.
[0112] The acquisition module 101 is used to read the bone matrix of each target bone from the second array corresponding to the game character based on the ID of each target bone used to control the equipment model to be rendered and the first array corresponding to the equipment model to be rendered; wherein, each target bone is loaded by the game character when the equipment model to be rendered is created, the first array stores the bone matrix index of each target bone, the second array stores the bone matrix of each loaded bone of the game character, and the bone matrix index represents the storage position of the bone matrix in the second array.
[0113] Rendering module 102 is used to render the rig model to be rendered based on the bone matrix of each target bone.
[0114] Optionally, the generation module 103 is used to update the mapping table corresponding to the game character at the current moment based on the ID of each target bone when creating the equipment model to be rendered, so as to obtain the updated mapping table; wherein, the mapping table stores multiple mapping information, and each mapping information includes the ID of a loaded bone of the game character and the bone matrix index; according to the ID of each target bone, the bone matrix index of each target bone is obtained from the updated mapping table to generate the first array.
[0115] Optionally, the generation module 103 is specifically used to determine the bone to be processed based on the ID of each target bone and the mapping relationship table. The bone to be processed is the target bone that has not been loaded by the game character at the current moment. By loading the bone to be processed, a bone matrix of the bone to be processed is generated. The bone matrix of the bone to be processed is stored in a second array, and a bone matrix index of the bone to be processed is generated according to the storage position of the bone matrix of the bone to be processed in the second array. The mapping information containing the ID of the bone to be processed and the bone matrix index is added to the mapping relationship table to update the mapping relationship table.
[0116] Optionally, when the generation module 103 determines the bone to be processed based on the ID and mapping relationship table of each target bone, it specifically determines that for each target bone, if there is no mapping information including the ID of the target bone in the mapping relationship table, the target bone is the bone to be processed.
[0117] Optionally, the update module 104 is used to update the mapping table at the current moment according to the label of each target bone used to control the deleted equipment model if there is a deleted equipment model for the game character, so as to obtain an updated mapping table; and use the updated mapping table to update the first array corresponding to the non-deleted equipment models of the game character.
[0118] Optionally, when updating the mapping table at the current moment based on the label of each target bone used to control the deleted equipment model, the update module 104 specifically determines the bone to be unloaded from all target bones based on the label of each target bone; deletes the mapping information including the ID of the bone to be unloaded from the mapping table; deletes the bone matrix of the bone to be unloaded from the second array according to the bone matrix index of the bone to be unloaded, and adjusts the storage position of each bone matrix that has not been deleted in the second array to obtain the updated second array; and updates the mapping table using the updated second array.
[0119] Optionally, when the update module 104 determines the bone to be unloaded based on the label of each target bone, it specifically determines that if the target bone is not a base bone of the game character based on the label of the target bone, then the target bone is used as the bone to be unloaded.
[0120] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the equipment model rendering device 100 described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0121] Furthermore, this embodiment of the invention also provides a computer device 200, please refer to... Figure 5The computer device 200 may include a memory 210 and a processor 220.
[0122] The processor 220 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits used to control the execution of a program for the equipment model rendering method provided in the above method embodiments.
[0123] The memory 210 may be a ROM or other type of static storage device capable of storing static information and instructions, RAM or other type of dynamic storage device capable of storing information and instructions, or an electrically erasable programmable-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. The memory 210 may exist independently and be connected to the processor 220 via a communication bus. The memory 210 may also be integrated with the processor 220. The memory 210 is used to store machine-executable instructions for executing the scheme of this application. The processor 220 is used to execute the machine-executable instructions stored in the memory 210 to implement the above-described method embodiments.
[0124] This invention also provides a computer-readable storage medium containing a computer program, which, when executed, can be used to perform related operations in the equipment model rendering method provided in the above-described method embodiments.
[0125] In summary, the equipment model rendering method, apparatus, computer device, and storage medium provided by this invention firstly read the bone matrix of each target bone from a second array corresponding to the game character, based on the ID of each target bone used to control the equipment model to be rendered and a first array corresponding to the equipment model to be rendered. Each target bone is loaded by the game character when the equipment model to be rendered is created. The first array stores the bone matrix index of each target bone, and the second array stores the bone matrix of each loaded bone of the game character. The bone matrix index represents the storage position of the bone matrix in the second array. Then, the equipment model to be rendered is rendered based on the bone matrix of each target bone. Because this invention sets a first array for the equipment model to be rendered and a second array for the game character, storing the bone matrix of each recorded bone of the game character in the second array, and storing the bone matrix index representing the storage position of the bone matrix in the second array, this avoids the waste of memory resources caused by generating an array for storing the bone matrix according to the maximum ID of the game character's bones.
[0126] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for rendering equipment models, characterized in that, The method includes: When creating the equipment model to be rendered, the mapping table corresponding to the game character at the current moment is updated based on the ID of each target bone used to control the equipment model to be rendered, resulting in the updated mapping table; wherein, the mapping table stores multiple mapping information, and each mapping information includes the ID of a loaded bone of the game character and the bone matrix index; Based on the ID of each target bone, the bone matrix index of each target bone is obtained from the updated mapping table to generate the first array corresponding to the equipment model to be rendered; Based on the ID of each target bone and the first array, read the bone matrix of each target bone from the second array corresponding to the game character; Each of the target bones is loaded by the game character when the equipment model to be rendered is created. The first array stores the bone matrix index of each target bone, and the second array stores the bone matrix of each loaded bone of the game character. The bone matrix index represents the storage position of the bone matrix in the second array. The equipment model to be rendered is rendered based on the bone matrix of each target bone.
2. The method as described in claim 1, characterized in that, The step of updating the mapping table corresponding to the game character at the current moment based on the ID of each target bone used to control the equipment model to be rendered includes: Based on the ID of each target bone and the mapping table, the bone to be processed is determined. The bone to be processed is the target bone that has not been loaded by the game character at the current moment. By loading the bone to be processed, a bone matrix of the bone to be processed is generated; The bone matrix of the bone to be processed is stored in the second array, and the bone matrix index of the bone to be processed is generated according to the storage position of the bone matrix of the bone to be processed in the second array. The mapping information, which includes the ID of the bone to be processed and the bone matrix index, is added to the mapping table to update the mapping table.
3. The method as described in claim 2, characterized in that, The step of determining the bone to be processed based on the ID of each target bone and the mapping table includes: For each target bone, if there is no mapping information including the ID of the target bone in the mapping table, then the target bone is used as the bone to be processed.
4. The method as described in claim 1, characterized in that, The method further includes: If the game character has a deleted equipment model, the mapping table at the current moment is updated according to the label of each target bone used to control the deleted equipment model, so as to obtain the updated mapping table. Using the updated mapping table, the first array corresponding to the undeletable equipment models of the game character is updated.
5. The method as described in claim 4, characterized in that, The step of updating the mapping table at the current moment based on the label used to control each target bone of the deleted equipment model includes: Based on the label of each target bone, determine the bones to be unloaded from all the target bones; Remove the mapping information, including the ID of the bone to be unloaded, from the mapping table; According to the bone matrix index of the bone to be unloaded, the bone matrix of the bone to be unloaded is deleted from the second array, and the storage position of each bone matrix that has not been deleted in the second array is adjusted to obtain the updated second array; The mapping table is updated using the updated second array.
6. The method as described in claim 5, characterized in that, The step of determining the bone to be unloaded based on the label of each target bone includes: For each target bone, if it is determined, based on the target bone's label, that the target bone is not a base bone of the game character, then the target bone is designated as a bone to be unloaded.
7. A device for rendering equipment models, characterized in that, The device includes: The generation module is used to update the mapping table corresponding to the game character at the current moment based on the ID of each target bone used to control the equipment model to be rendered when creating the equipment model to be rendered, so as to obtain the updated mapping table; wherein, the mapping table stores multiple mapping information, and each mapping information includes the ID of a loaded bone of the game character and the bone matrix index; according to the ID of each target bone, the bone matrix index of each target bone is obtained from the updated mapping table to generate the first array corresponding to the equipment model to be rendered; The acquisition module is used to read the bone matrix of each target bone from the second array of the game character based on the ID of each target bone and the first array; Each of the target bones is loaded by the game character when the equipment model to be rendered is created. The first array stores the index of the bone matrix of each target bone, and the second array stores the bone matrix of each loaded bone of the game character. The index of the bone matrix represents the storage position of the bone matrix in the second array. The rendering module is used to render the equipment model to be rendered based on the bone matrix of each target bone.
8. A computer device, characterized in that, It includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the equipment model rendering method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the equipment model rendering method as described in any one of claims 1-6.
Citation Information
Patent Citations
Game role reloading method and device, computer storage medium and electronic device
CN109771947A