CN-121982170-A - Method and device for generating game non-player characters
Abstract
The application belongs to the technical field of game modeling, and discloses a method and a device for generating a non-player character in a game, wherein the method comprises the steps of randomly extracting a trunk model set to obtain a target trunk model and a corresponding body type proportion label; inquiring each limb model set according to the association rule database and the body type proportion labels of the target trunk models to obtain compatible limb model lists corresponding to each limb model set, randomly extracting each compatible limb model list to obtain a plurality of target limb models, judging whether interface parameters of the target trunk models and each target limb model are matched or not, if yes, combining the target trunk models and each target limb model to obtain candidate role models, and responding to a selection instruction, wherein the candidate role models corresponding to the selection instruction are used as non-player roles. According to the method, a developer only needs to construct a certain number of limb models and trunk models, and large-batch NPC character generation with different types can be realized through random combination.
Inventors
- YANG TAO
- CHEN ZHIQIN
- Bai Bingshan
Assignees
- 芜湖豆邀玩网络科技有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20251231
Claims (20)
- 1. A method for generating a game non-player character, comprising: Acquiring a correlation rule database, a trunk model set and a plurality of limb model sets; Randomly extracting the trunk model set to obtain a target trunk model and a corresponding body type proportion label; inquiring each limb model set according to the association rule database and the body type proportion labels of the target trunk models to obtain a compatible limb model list corresponding to each limb model set; Randomly extracting each compatible limb model list to obtain a plurality of target limb models; Judging whether the interface parameters of the target trunk model and each target limb model are matched, if yes, combining the target trunk model and each target limb model to obtain candidate role models; and responding to the selection instruction, and taking the candidate character model corresponding to the selection instruction as a non-player character.
- 2. The method of claim 1, wherein the set of torso models includes a plurality of torso models and body type scale labels corresponding to each of the torso models, and wherein the set of limb models includes a plurality of limb models corresponding to a same limb portion and body type scale labels corresponding to each of the limb models; the association rule database comprises compatible label queues corresponding to various body type proportion labels; inquiring each limb model set according to the association rule database and the body type proportion labels of the target trunk models to obtain a compatible limb model list corresponding to each limb model set, wherein the method comprises the following steps: inquiring the association rule database according to the body type proportion label of the target trunk model to obtain a compatible label queue corresponding to the body type proportion label of the target trunk model, and taking the compatible label queue as a target compatible label queue; And placing the body type proportion labels in the limb model set into the limb model corresponding to the limb model set in the target compatible label queue.
- 3. The method of claim 2, wherein the interface parameters of the torso model include torso height and a plurality of limb connection point coordinates, and wherein the interface parameters of the limb model include torso connection point coordinates and bone length, and wherein the determining whether the interface parameters of the target torso model and each of the target limb models match comprises: Determining the corresponding coordinates of a target limb connection point of the target limb model on the target trunk model; judging whether the body connecting point coordinates of the target limb model are aligned with the target limb connecting point coordinates; If not, the interface parameters are not matched, if yes, the ratio of the trunk height to the bone length of each target limb model is calculated to meet the preset ergonomic range, if yes, the interface parameters are matched, and if not, the interface parameters are not matched.
- 4. A method of generating a game non-player character according to claim 3, wherein said combining said target torso model and each of said target limb models to obtain candidate character models comprises: connecting the target limb model and the target trunk model according to the body connecting point coordinates of the target limb model and the corresponding target limb connecting point coordinates of the target limb model on the target trunk model; Acquiring skin weight distribution diagrams of all vertexes on the target limb model and the target trunk model, wherein the skin weight distribution diagrams comprise weights of all bones in the target limb model and the target trunk model by the vertexes; determining a transition region according to a seam of the target limb model and the target trunk model; And carrying out weight fusion on each vertex of the transition region based on the skin weight distribution map to obtain the latest weight of each vertex to each skeleton, and normalizing each latest weight of each vertex to obtain the candidate role model.
- 5. The method of claim 4, wherein the set of limb models further comprises compatible equipment tags corresponding to the respective limb models, the method further comprising: acquiring an equipment model set, and determining at least one target equipment model in the equipment model set according to compatible equipment labels of the target limb model after connecting the target limb model and the target trunk model; the target equipment model and the target limb model are combined.
- 6. The method of generating a game non-player character according to claim 1, further comprising: After candidate character models are obtained, calculating the center of gravity of the candidate character models; And judging whether the gravity center is offset, if so, adjusting the distance between the two leg limb models of the candidate role model according to the offset direction of the gravity center until the gravity center of the candidate role model is not offset.
- 7. The method of generating a game non-player character according to claim 1, further comprising: And after the candidate character model corresponding to the selection instruction is used as a non-player character, acquiring a preset core action and a trigger instruction corresponding to the preset core action, and binding the trigger instruction with the non-player character.
- 8. The method of generating a game non-player character according to claim 7, further comprising: After the candidate character model corresponding to the selection instruction is used as a non-player character, determining joint motion constraint of the non-player character according to the body type proportion label of the candidate character model; Causing the non-player character to perform a preset core action based on the articulation constraints and detecting collision data between a target torso model and each target limb model of the non-player character; and updating the articulation constraint of the non-player character according to the collision data until the non-player character does not have collision data when executing a preset core action based on the updated articulation constraint.
- 9. The method of generating a game non-player character according to claim 8, further comprising: After the updating of the joint movement constraint is finished, judging whether the updated joint movement constraint covers the movement range of the preset core action, and if not, deleting the non-player character.
- 10. The method of generating a game non-player character according to claim 1, further comprising: acquiring a game map, a movement starting point coordinate and a movement ending point coordinate of the non-player character; Generating route information from the movement start point coordinates to the movement end point coordinates according to a path planning algorithm; Acquiring the gate duration of the game map and a plurality of different moving speeds of the non-player character; And generating movement data of the non-player character according to the gate duration, the movement speed and the route information, wherein the movement data comprises the movement speeds of the non-player character on different road sections of the route information.
- 11. The method of generating a game non-player character according to claim 10, wherein the generating movement data of the non-player character according to the gate duration, the respective movement speeds, and the route information includes: randomly dividing the route information according to a preset segment number to obtain a plurality of road segments; Randomly distributing the moving speed of one non-player character to each road section as an initial speed; calculating a moving duration according to the length of each road section and the initial speed; And if the moving time length is longer than the checkpoint time length, reducing the maximum initial speed in each road section according to a preset adjustment step, and if the moving time length is shorter than the checkpoint time length, increasing the minimum initial speed in the road section according to the preset adjustment step until the moving time length is equal to the checkpoint time length.
- 12. A game non-player character generating apparatus comprising: The acquisition module is used for acquiring the association rule database, the trunk model set and the limb model sets; the trunk module is used for randomly extracting the trunk model set to obtain a target trunk model and a corresponding body type proportion label; the tag query module is used for querying each limb model set according to the association rule database and the body type proportion tags of the target trunk model to obtain a compatible limb model list corresponding to each limb model set; The limb module is used for randomly extracting each compatible limb model list to obtain a plurality of target limb models; the combination module is used for judging whether the interface parameters of the target trunk model and each target limb model are matched, if yes, combining the target trunk model and each target limb model to obtain candidate role models; And the selection module is used for responding to the selection instruction and taking the candidate character model corresponding to the selection instruction as a non-player character.
- 13. The apparatus for generating a game non-player character according to claim 12, wherein the trunk model set includes a plurality of trunk models and body type scale labels corresponding to the trunk models, and wherein the limb model set includes a plurality of limb models corresponding to the same limb portion and body type scale labels corresponding to the limb models; the association rule database comprises compatible label queues corresponding to various body type proportion labels; The label inquiry module is specifically used for inquiring the association rule database according to the body type proportion labels of the target trunk model to obtain a compatible label queue corresponding to the body type proportion labels of the target trunk model and serve as a target compatible label queue, and placing the limb model of which the body type proportion labels in the limb model set fall into the target compatible label queue into a compatible limb model list corresponding to the limb model set.
- 14. The device for generating a game non-player character according to claim 13, wherein the interface parameters of the torso model include a torso height and a plurality of limb connection point coordinates, the interface parameters of the limb model include a torso connection point coordinate and a bone length, the combination module is specifically configured to determine a target limb connection point coordinate corresponding to the target limb model on the target torso model, determine whether the torso connection point coordinate of the target limb model and the target limb connection point coordinate are aligned, if not, the interface parameters are not matched, if yes, calculate whether a ratio of the torso height to the bone length of each of the target limb models satisfies a preset ergonomic range, if yes, the interface parameters are matched, and if not, the interface parameters are not matched.
- 15. The device for generating a game non-player character according to claim 14, wherein the combining module is further specifically configured to connect the target limb model and the target torso model according to body connection point coordinates of the target limb model and corresponding target limb connection point coordinates of the target limb model on the target torso model, obtain skin weight distribution diagrams of each vertex on the target limb model and the target torso model, where the skin weight distribution diagrams include weights of the vertex on each bone in the target limb model and the target torso model, determine a transition region according to joints of the target limb model and the target torso model, perform weight fusion on each vertex of the transition region based on the skin weight distribution diagrams, obtain latest weights of each vertex on each bone, and normalize each latest of the vertex, and obtain the candidate character weight model.
- 16. The apparatus for generating a game non-player character according to claim 15, wherein the set of limb models further comprises compatible equipment tags corresponding to the respective limb models, the apparatus further comprising: the equipment combination module is used for acquiring an equipment model set, determining at least one target equipment model in the equipment model set according to compatible equipment labels of the target limb models after the target limb models and the target trunk models are connected, and combining the target equipment model and the target limb models.
- 17. The game non-player character generating device of claim 12, further comprising: And judging whether the gravity center is offset or not, if so, adjusting the distance between two leg limb models of the candidate character model according to the offset direction of the gravity center until the gravity center of the candidate character model is not offset.
- 18. The game non-player character generating device of claim 12, further comprising: And the action combination module is used for acquiring a preset core action and a trigger instruction corresponding to the preset core action after taking the candidate character model corresponding to the selection instruction as a non-player character, and binding the trigger instruction with the non-player character.
- 19. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the method for generating a game non-player character according to any of claims 1 to 11 when the computer program is executed.
- 20. A computer-readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of generating a game non-player character according to any of claims 1 to 11.
Description
Method and device for generating game non-player characters Technical Field The application relates to the technical field of game modeling, in particular to a method and a device for generating a non-player character of a game. Background The modeling of non-player characters (NPCs) in a game scene requires modeling and binding bones, so that the period from modeling to application of the non-player characters is about 1-2 days at present, and therefore, in games requiring a large number of NPCs, a large number of NPCs are often quickly generated in batches by using a copying mode after modeling a certain number of NPC models and put into the game scene. However, NPCs generated in batches by means of copying are serious in appearance homogenization, repeated feeling is easily generated by players, the game experience is poor, and the modeled NPCs cannot realize multiplexing of game items with different artistic styles. Disclosure of Invention The application provides a method and a device for generating game non-player characters, which can realize the generation of NPC characters with different types in a large quantity by random combination only by constructing a certain number of limb models and trunk models by developers. In a first aspect, an embodiment of the present application provides a method for generating a game non-player character, including: Acquiring a correlation rule database, a trunk model set and a plurality of limb model sets; randomly extracting a trunk model set to obtain a target trunk model and a corresponding body type proportion label; Inquiring each limb model set according to the association rule database and the body type proportion labels of the target trunk models to obtain a compatible limb model list corresponding to each limb model set; Randomly extracting each compatible limb model list to obtain a plurality of target limb models; judging whether the interface parameters of the target trunk model and each target limb model are matched, if so, combining the target trunk model and each target limb model to obtain candidate role models; And responding to the selection instruction, and taking the candidate character model corresponding to the selection instruction as a non-player character. Further, the trunk model set comprises a plurality of trunk models and body type proportion labels corresponding to all trunk models, the limb model set comprises a plurality of limb models corresponding to the same limb part and body type proportion labels corresponding to all limb models, and the association rule database comprises compatible label queues corresponding to all body type proportion labels; inquiring each limb model set according to the association rule database and the body type proportion labels of the target trunk model to obtain a compatible limb model list corresponding to each limb model set, wherein the method comprises the following steps: Inquiring a correlation rule database according to the body type proportion labels of the target trunk model to obtain compatible label queues corresponding to the body type proportion labels of the target trunk model, and taking the compatible label queues as target compatible label queues; And placing the limb models of which the body type proportion labels in the limb model set fall into the target compatible label queue into a compatible limb model list corresponding to the limb model set. Further, the interface parameters of the trunk model comprise trunk height and a plurality of limb connection point coordinates, and the interface parameters of the limb model comprise trunk connection point coordinates and bone lengths; The determining whether the interface parameters of the target trunk model and each target limb model are matched includes: Determining the corresponding coordinates of the connecting points of the target limbs on the target trunk model; judging whether the body connecting point coordinates of the target limb model are aligned with the target limb connecting point coordinates; If not, the interface parameters are not matched, if so, the ratio of the trunk height to the bone length of each target limb model is calculated to meet the preset ergonomic range, if so, the interface parameters are matched, otherwise, the interface parameters are not matched. Further, the combining the target trunk model and each target limb model to obtain candidate character models includes: Connecting the target limb model and the target trunk model according to the body connecting point coordinates of the target limb model and the corresponding target limb connecting point coordinates of the target limb model on the target trunk model; acquiring skin weight distribution diagrams of all vertexes on the target limb model and the target trunk model, wherein the skin weight distribution diagrams comprise weights of the vertexes on all bones in the target limb model and the target trunk model; determining a transition region accordi