Virtual object processing method and device, program product and electronic equipment
By combining the target image with a virtual model, the motion information of virtual object vertices is obtained and controlled, and the problem of realizing dynamic effects of virtual objects in the existing technology is solved, and efficient and low-cost dynamic effects generation of virtual objects is achieved.
Patent Information
- Application Number
- CN202510164611.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-13
- Publication Date
- 2025-05-30
AI Technical Summary
In the prior art, realizing the dynamic effect of virtual objects requires artists to manually draw a large number of virtual object maps, which consumes a lot of manpower and time costs and is less efficient.
By meshing the target image to obtain a map, combining the virtual model to generate a virtual object, and obtaining the continuous motion information and motion event information of the vertex, controlling the vertex motion based on this information to achieve the dynamic effect of the virtual object.
Without relying on manual drawing of materials, high-quality dynamic effects of virtual objects are achieved, reducing labor and time costs, and improving the complexity and authenticity of dynamic effects.
Smart Images

Figure CN120053965A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and in particular, to a method for processing virtual objects, an apparatus for processing virtual objects, a computer program product, and an electronic device. Background Art
[0002] In the production processes of games, animations, movies, etc., it is often necessary to present dynamic effects of virtual objects, such as the effect of flames jumping when burning, the effect of river water flowing, etc.
[0003] In related technologies, a large number of virtual object images need to be manually drawn by artists, and different virtual object images are displayed at different time points to achieve dynamic effects. This method consumes a large amount of human and time costs and has low efficiency. Summary of the Invention
[0004] The present disclosure provides a method for processing virtual objects, an apparatus for processing virtual objects, a computer program product, and an electronic device, so as to at least to some extent solve the problem of relying on manual drawing of virtual object images in related technologies.
[0005] According to a first aspect of the present disclosure, there is provided a method for processing virtual objects, the method including: performing grid processing on a target image to obtain a texture map, and generating a virtual object according to the texture map and a virtual model; the virtual object includes a plurality of vertices; obtaining first motion information of the vertices performing continuous motion within a preset time range; determining second motion information of the vertices according to a motion event of the virtual object; the second motion information represents the motion information of the vertices in the motion event; controlling the vertices to move based on the first motion information and the second motion information, and obtaining a dynamic effect of the virtual object according to the movement of the vertices.
[0006] According to a second aspect of the present disclosure, there is provided an apparatus for processing virtual objects, the apparatus including: a virtual object generation module configured to perform grid processing on a target image to obtain a texture map, and generate a virtual object according to the texture map and a virtual model; the virtual object includes a plurality of vertices; a first motion information determination module configured to obtain first motion information of the vertices performing continuous motion within a preset time range; a second motion information determination module configured to determine second motion information of the vertices according to a motion event of the virtual object; the second motion information represents the motion information of the vertices in the motion event; a motion control module configured to control the vertices to move based on the first motion information and the second motion information, and obtain a dynamic effect of the virtual object according to the movement of the vertices.
[0007] According to a third aspect of the present disclosure, there is provided a computer program product including a computer program which, when executed by a processor, implements the method of the first aspect and its possible implementations as described above.
[0008] According to a fourth aspect of the present disclosure, there is provided an electronic device including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the method of the first aspect and its possible implementations by executing the executable instructions.
[0009] The technical solution of the present disclosure has the following beneficial effects:
[0010] The target image is meshed to obtain a texture map, the texture map is combined with a virtual model to generate a virtual object. For the vertices of the virtual object, first motion information of its continuous motion is obtained, and second motion information is determined according to the motion events of the virtual object. Based on the first motion information and the second motion information, the vertices are controlled to move, and the movement of the vertices brings changes in display effects such as the texture map, thereby forming a dynamic effect of the virtual object. It can be seen that this solution provides a method for automatically generating a virtual dynamic effect, which can achieve the dynamic effect of the virtual object without relying on manually drawn materials, reducing the labor and time costs. Moreover, by combining the first motion information of continuous motion and the second motion information in the case of motion events, the vertices are controlled to execute a combination of two motions, improving the complexity of the vertex motion and making the dynamic effect based on the vertex motion more complex and realistic, which is beneficial to achieving a high-quality dynamic effect. Description of the Drawings
[0011] Figure 1 A flowchart showing a method for processing a virtual object in an exemplary embodiment;
[0012] Figure 2 A flowchart showing a method for determining the first motion information in an exemplary embodiment;
[0013] Figure 3 A flowchart showing a method for controlling vertex motion in an exemplary embodiment;
[0014] Figure 4 A flowchart showing a method for generating an animation in an exemplary embodiment;
[0015] Figure 5 A schematic structural diagram showing a virtual object processing apparatus in an exemplary embodiment;
[0016] Figure 6 A schematic structural diagram showing an electronic device in an exemplary embodiment. Detailed Embodiments
[0017] Exemplary embodiments of the present disclosure will be described more fully hereinafter with reference to the accompanying drawings.
[0018] The accompanying drawings are schematic diagrams of the present disclosure and are not necessarily drawn to scale. Some of the block diagrams shown in the accompanying drawings may be functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, or in hardware modules or integrated circuits, or in networks, processors or microcontrollers. The embodiments can be implemented in various forms and should not be construed as limited to the examples set forth herein. The features, structures or characteristics described in the present disclosure can be combined in one or more embodiments in any suitable manner. In the following description, numerous specific details are provided to give a full understanding of the embodiments of the present disclosure. However, those skilled in the art should be aware that one or more of the specific details may be omitted when implementing the technical solutions of the present disclosure, or other methods, components, devices, steps, etc. may be used to replace one or more of the specific details.
[0019] In the related art, to achieve the dynamic effects of virtual objects such as flame animations, a frame-by-frame hand-drawing method is adopted, where artists manually draw a large number of virtual object images, and by setting different time points to display different virtual object images, the dynamic effects are achieved. This method consumes a large amount of human and time costs and has low efficiency. Moreover, the reusability of the drawn materials is low, and artists often need to draw materials separately for different projects, increasing the project cycle.
[0020] In view of the above problems, exemplary embodiments of the present disclosure provide a virtual object processing method that can achieve high-quality dynamic effects of virtual objects without relying on the method of manually drawing materials.
[0021] Figure 1 An exemplary process of the virtual object processing method is shown and may include the following steps:
[0022] Step S110, performing a grid processing on a target image to obtain a texture map, and generating a virtual object according to the texture map and a virtual model; the virtual object includes a plurality of vertices;
[0023] Step S120, obtaining first motion information of the vertices performing continuous motion within a preset time range;
[0024] Step S130, determining second motion information of the vertices according to the motion events of the virtual object; the second motion information represents the motion information of the vertices in the motion events;
[0025] Step S140, controlling the vertices to move based on the first motion information and the second motion information, and obtaining the dynamic effects of the virtual object according to the motion of the vertices.
[0026] Based on Figure 1 the method shown in Figure 1 , the target image is meshed to obtain a texture map, the texture map is combined with a virtual model to generate a virtual object. For the vertices of the virtual object, the first motion information of its continuous motion is obtained, and the second motion information is determined according to the motion events of the virtual object. Based on the first motion information and the second motion information, the vertices are controlled to move. The movement of the vertices brings changes in display effects such as texture maps, thus forming the dynamic effect of the virtual object. It can be seen that this solution provides a method for automatically generating virtual dynamic effects, which can achieve the dynamic effect of virtual objects without relying on manually drawn materials, reducing the labor and time costs. Moreover, by the first motion information of continuous motion and the second motion information in the case of motion events, the combination of two motions is controlled for the vertices, improving the complexity of the vertex motion, making the dynamic effect based on the vertex motion more complex and realistic, and facilitating the realization of high-quality dynamic effects.
[0027] The following makes a specific description of Figure 1 each step.
[0028] Referring to Figure 1 , in step S110, the target image is meshed to obtain a texture map, and a virtual object is generated according to the texture map and the virtual model; the virtual object includes multiple vertices.
[0029] Among them, the target image provides the appearance of the virtual object, which can be obtained by any means. In one implementation, the virtual object processing method may further include the following steps:
[0030] Obtain the prompt information for describing the target image;
[0031] Perform text-to-image processing on the prompt information through a preset image generation model to obtain the target image.
[0032] Among them, the preset image generation model is a machine learning model for generating images, which can be any type of model such as a neural network. For example, it can be a model based on architectures such as GAN (Generative Adversarial Network), or a diffusion model, a stable diffusion model, etc.
[0033] The prompt information can be input by the user, describing what kind of image is needed according to the style, characteristics, etc. of the virtual object. For example, if the virtual object is a flame, the prompt information can be text information describing the characteristics of the flame. The prompt information is input into the preset image generation model, and the preset image generation model performs text-to-image processing to generate the target image.
[0034] In one implementation, the target image can be obtained by calling an interface that provides an image generation service, such as the platform API (Application Programming Interface) that provides the DALL-E (an image generation system) service, and inputting the prompt information.
[0035] The generation process of the target image can refer to the following code:
[0036] Import abc # abc represents a preset image generation model or an image generation service interface, and the image generation service can deploy the preset image generation model
[0037] # Set the API key
[0038] abc.api_key = 'YOUR_API_KEY_HERE'
[0039] # Define a function to generate images, which can be implemented by calling the preset image generation model
[0040] def generate_images(prompt, n = 1, size = '1024x1024'):
[0041] response = abc.Image.create(
[0042] prompt = prompt, # Define the input prompt information
[0043] n = n, # Define the number of images to be generated
[0044] size = size # Define the size of the image )
[0046] return response['data'] # Return the generated image data
[0047] prompt = "A perfect circle with a high-intensity yellow in the center and a uniform color gradient outward. The further away from the center of the circle, the purer the color." # Input the prompt information, and the prompt information here is an exemplary text
[0048] number_of_images = 30 # Generate 30 images
[0049] # Generate images
[0050] images = generate_images(prompt, n=number_of_images)
[0051] # Save the generated images
[0052] for i, image in enumerate(images):
[0053] with open(f'image_{i + 1}.png', 'wb') as f:
[0054] f.write(image['binary']) # Save the image file to obtain the target image
[0055] It should be understood that the present disclosure does not limit the number of target images. For example, any number of target images can be generated by a preset image generation model.
[0056] The image output by the preset image generation model can be directly used as the target image, or the image output by the preset image generation model can be further processed, such as cropping and scaling the image according to the size of the virtual object or virtual model to obtain the target image.
[0057] By performing a meshing process on the target image, a texture map is obtained. Among them, a mesh can be generated in the target image according to a preset mesh size. The mesh provides reference information such as position for different regions in the target image, and the target image can be divided into individual mesh cells. The target image with mesh information can be used as the texture map.
[0058] The virtual model can be a textureless model of the virtual object (i.e., a "white model"). This exemplary embodiment supports processing virtual objects in two dimensions, three dimensions, etc., so the virtual model can be a two-dimensional model or a three-dimensional model, etc. In one embodiment, the virtual model can be a skeletal model, which consists of one or more segments of virtual bones and includes a number of bone points.
[0059] The texture map and the virtual model can be combined, such as wrapping the texture map on the surface of the virtual model to achieve the purpose of skinning and form a virtual object.
[0060] In one embodiment, generating the virtual object according to the texture map and the virtual model may include the following steps:
[0061] Determine the mapping relationship between the bone points of the virtual model and the texture map, and wrap the texture map on the surface of the virtual model according to the mapping relationship to form a virtual object; the vertices of the virtual object include the bone points and / or the mesh points in the texture map.
[0062] Among them, the mapping relationship between the bone points of the virtual model and the texture map may include the mapping relationship between the bone points and the texture coordinates of the texture map, that is, which coordinate point (i.e., sampling point) in the texture map the bone point corresponds to. The mapping relationship can be determined based on the virtual model and the initial texture map, or the texture map can be scaled by a certain ratio, and the mapping relationship can be determined based on the virtual model and the scaled texture map.
[0063] The methods for determining the mapping relationship include but are not limited to the following: Artists manually set the texture coordinates in the texture map corresponding to the bone points of the virtual model. For example, artists can set the texture coordinates corresponding to a part of the bone points (such as corner points) of the virtual model, and then the program calculates the texture coordinates corresponding to other bone points. Unfold the surface of the three-dimensional virtual model into a two-dimensional plane, convert the bone points into points on the two-dimensional plane, and determine the mapping relationship between the bone points and the texture map according to the transformation relationship (such as tiling, offset, rotation relationship, etc.) between the two-dimensional plane and the texture map. Through projection (such as spherical projection, cylindrical projection), project the bone points of the virtual model onto the texture map (the texture map can match the projection method. For example, when using spherical projection, the texture map can be converted into a spherical texture map; when using cylindrical projection, the texture map can be converted into a cylindrical texture map), to obtain the mapping relationship between the bone points and the texture map.
[0064] According to the mapping relationship, wrap the texture map around the surface of the virtual model, so that the bone points of the virtual model coincide with the corresponding coordinate points on the texture map, forming a virtual model.
[0065] In this exemplary embodiment, dynamic effects are achieved by controlling the movement of the vertices of the virtual model. The vertices of the virtual model may include bone points and / or grid points in the texture map. Exemplarily, the virtual model is a two-dimensional model, and both the bone points and the grid points are located on the surface of the virtual model.
[0066] Continue to refer to Figure 1 , in step S120, obtain the first motion information of the vertex performing continuous motion within a preset time range.
[0067] In this exemplary embodiment, two motion modes can be set for the virtual object: one is continuous motion within a preset time range, representing the normal motion of the virtual object. Among them, the preset time range can be set according to specific requirements. For example, the dynamic effect of the virtual object can be realized by generating an animation, and the preset time range can be the time range of the entire animation. The other is motion event-driven motion, representing abnormal motion performed at a specific moment or under specific conditions. By combining the two motion modes, the complexity and authenticity of the motion are increased.
[0068] The first motion information describes the motion characteristics of vertices in the continuous motion state of the virtual object. For example, it can include the basic motion speed of the vertices in the continuous motion state and the first position change amount (referring to the position change amount of the vertices in the continuous motion state, and the second motion change amount below refers to the position change amount of the vertices in the motion event). The first motion information can be set manually, such as set by the producer of the virtual object animation, or the numerical range of the first motion information can be set manually, and the program generates specific first motion information within the numerical range.
[0069] Continue to refer to Figure 1 , in step S130, according to the motion event of the virtual object, determine the second motion information of the vertex; the second motion information represents the motion information of the vertex in the motion event.
[0070] When setting the motion event, motion parameters are usually specified. If no motion parameters are specified, the system can set default motion parameters or randomly generate motion parameters, and determine the second motion information according to the motion parameters. For example, the event motion speed (referring to the motion speed in the motion event, different from the basic motion speed), the second position change amount, the position change threshold, etc. can be obtained from the information of the motion event as the second motion information.
[0071] Exemplarily, the motion event can be set in the timeline of the virtual object. For example, the developer can add key frames in the timeline and set the information of the motion event in the key frames. The moment corresponding to the motion event is the moment of the key frame, and the motion performed by the virtual object in the motion event is the motion performed in the key frame. The second motion information can represent the motion information of the vertices of the virtual object in the motion event, that is, the motion information in the key frame.
[0072] Continue to refer to Figure 1 , in step S140, control the vertex to move based on the first motion information and the second motion information, and obtain the dynamic effect of the virtual object according to the motion of the vertex.
[0073] Control the vertex to move in the conventional motion mode based on the first motion information, and control the vertex to move in the motion event based on the second motion information. The motion result of the vertex is the superposition of the two motion modes. According to the motion of the vertex, the display effect of the texture changes. For example, after the vertex moves, the sampling information of the vertex in the texture changes, and the position relationship between different vertices changes, causing the grid of the rectangle in the texture to deform accordingly, thereby causing the appearance of the virtual object to change, and thus obtaining the dynamic effect.
[0074] In one implementation, the vertices of the virtual object include grid points. The motion of the grid points on the virtual model can be controlled, and the motion of the grid points directly causes the change of the display effect of the texture on the virtual model, generating a dynamic effect. Refer toFigure 2 As shown above, the first motion information for obtaining the continuous motion of vertices within a preset time range may include the following steps S210 to S230:
[0075] Step S210, determining the weight information of grid points, where the weight information includes the weights corresponding to one or more bone points bound to the grid points.
[0076] Among them, a binding relationship between grid points and bone points can be established so that each grid point is bound to one or more bone points. In the case of binding, when a bone point moves, it will drive the bound grid point to move. The weight information of the grid point includes the weights corresponding to the respective bone points bound to the grid point, and this weight can be used to calculate the motion of the grid point, that is, the motion of the grid point is the result of weighting the motions of the respective bound bone points.
[0077] In one implementation manner, the above determining the weight information of grid points may include the following steps:
[0078] According to the mapping relationship between bone points and texture maps, determining the texture map positions corresponding to the bone points;
[0079] If the distance between the grid point and the texture map position corresponding to the bone point does not exceed a preset distance, then bind the grid point and the bone point, and determine the weight corresponding to the bone point according to the distance, where the weight is negatively correlated with the distance.
[0080] Among them, according to the mapping relationship between bone points and texture maps, determining the coordinate points corresponding to the bone points in the texture map, that is, the texture map positions corresponding to the bone points. Each bone point can have a certain influence range, and this influence range can be determined by a preset distance. For example, it can be a circular or spherical range centered on the bone point with the preset distance as the radius. The preset distance can be determined according to experience or specific circumstances, or can be adjusted according to the influence of the bone. For example, the influences of different bones may be different, and corresponding preset distances can be set for the bone points on the bone according to the influence, indicating that for a bone with a greater influence, the influence range of its bone points is larger.
[0081] Calculating the distances between each grid point and the texture map positions corresponding to each bone point (such as the Euclidean distance can be used), for example, each grid point and each bone point can be combined pairwise to calculate the distance. If the distance does not exceed the preset distance, it means that the grid point is within the influence range of the bone point, bind the two, and determine the weight corresponding to the bone point according to the distance. Generally, the greater the distance, the smaller the influence exerted by the bone point on the grid point, that is, the smaller the weight.
[0082] In one embodiment, "1 / square of the distance" can be used as the initial weight, and the initial weights corresponding to each bone point bound to each grid point are normalized, that is, it is ensured that the sum of the weights corresponding to each bone point bound to each grid point is 1, or the weights of the grid points within the influence range of each bone point are normalized to ensure that the sum of the weights within the influence range of each bone point is 1, so as to obtain the final weight corresponding to the bone point.
[0083] Exemplarily, the bone points and grid points can be bound through an automatic skinning algorithm, and the weight information can be determined. Refer to the following code:
[0084] def calculate_weight(distance):
[0085] # Weight calculation method, the closer the distance, the greater the weight
[0086] if distance == 0:
[0087] return 1.0
[0088] return 1 / (distance**2)
[0089] def automatic_skinning(mesh,bones):
[0090] for vertex in mesh.vertices:
[0091] influences = []
[0092] for bone in bones:
[0093] distance = calculate_distance(vertex,bone)
[0094] weight = calculate_weight(distance)
[0095] influences.append((weight,bone))
[0096] # Normalize weights
[0097] total_weight = sum([influence[0] for influence in influences])
[0098] for i in range(len(influences)):
[0099] influences[i] = (influences[i][0] / total_weight, influences[i][1])
[0100] # Bind vertices to bones
[0101] vertex.influences = influences
[0102] def calculate_distance(vertex, bone):
[0103] # Distance calculation function
[0104] dx = vertex.x - bone.x
[0105] dy = vertex.y - bone.y
[0106] return (dx ** 2 + dy ** 2) ** 0.5
[0107] # Example usage
[0108] mesh = spine.Mesh.load("path / to / mesh")
[0109] bones = spine.Skeleton.load("path / to / skeleton")
[0110] automatic_skinning(mesh, bones)
[0111] By executing the above automatic skinning algorithm, the mesh points are automatically bound to the bone points, and the weights are calculated to enable the movement of the mesh points driven by the movement of the bone points in subsequent steps.
[0112] Step S220, obtain the third motion information of the bone points for continuous movement within a preset time range.
[0113] Among them, the third motion information describes the motion characteristics of the bone points in the continuous motion state of the virtual object. For example, it can include the basic motion speed of the bone points in the continuous motion state and the third position change amount (referring to the position change amount of the bone points in the continuous motion state, and the second motion change amount below refers to the position change amount in the motion event). The third motion information can be set manually, such as set by the producer of the virtual object animation, or the numerical range of the third motion information can be set manually, and the program generates specific third motion information within the numerical range.
[0114] Step S230: Weight the third motion information of the bone points bound to the grid points according to the weight information to obtain the first motion information of the grid points for continuous motion within a preset time range.
[0115] For example, grid point A is bound to three bone points B1, B2, and B3, and the weight information of grid point A includes the weights w1, w2, and w3 corresponding to bone points B1, B2, and B3 respectively. The third motion information obtained in step S320 includes the basic motion speeds v1, v2, and v3 (all of which can be vectors) of bone points B1, B2, and B3. By weighting, the basic motion speed of grid point A is obtained as w1v1 + w2v2 + w3v3.
[0116] Based on Figure 2 the above solution, obtaining the first motion information of the grid points according to the third motion information of the bone points can control the movement of the grid points during the movement of the virtual object, and realize the dynamic change of the texture display effect driven by the bones.
[0117] In one implementation, the first motion information includes the basic motion speed. Referring to Figure 3 as shown above, controlling the vertices to move based on the first motion information and the second motion information may include the following steps S310 and S320:
[0118] Step S310: At non-key frames where no motion event occurs within a preset time range, control the vertices to move based on the basic motion speed.
[0119] The basic motion speed describes the continuous motion speed of the vertices within a preset time range. Exemplarily, the preset time range can be set to the time range of the entire virtual object animation, including each frame of the virtual object animation. The animator can set key frames on the time axis of the virtual object animation and set motion events, and other frames are non-key frames. Based on the basic motion speed, update the positions of the vertices in each non-key frame to achieve the normal motion of the vertices.
[0120] In one implementation, the above controlling the vertices to move based on the basic motion speed at non-key frames where no motion event occurs within a preset time range may include the following steps:
[0121] In response to not detecting a motion event at the current frame, determine that the current frame is a non-key frame, and obtain the time increment between the current time and the time of the last motion of the vertex;
[0122] Determine the first position change amount based on the basic motion speed and the time increment, and control the vertices to move according to the first position change amount.
[0123] Among them, by registering an event listener to listen for motion events, if no motion event is detected in the current frame, it is determined that the current frame is a non-critical frame, and it is determined that the vertex performs a regular motion in the current frame. The time increment (deltaTime) between the current time and the time of the vertex's last motion can be obtained. For example, when controlling the vertex to move in units of each frame, the time increment can be the duration of one frame. The base motion speed and the time increment can be multiplied to calculate the first position change amount, that is, the change amount of the vertex's position relative to the position after the last motion after this motion. If the time increment is the duration of one frame, the first position change amount is the position change amount of the vertex in one frame. The vertex is controlled to move according to the first position change amount. This can ensure the stability of regular motion.
[0124] Exemplarily, the motion script information of the virtual object can be set to describe the regular motion logic of the virtual object, and it can be set that the virtual object performs regular motion in a loop or continuously to simulate the characteristics of virtual objects such as flames and rivers. The motion script information can refer to the following code:
[0125] -- Set the base motion speed
[0126] local speedX=1
[0127] local speedY=1
[0128] function onUpdate(deltaTime)
[0129] -- Obtain the current animation state and mesh
[0130] local animationState=skeletonRenderer.state
[0131] local mesh=skeleton.findSlot("yourMeshSlot").attachment
[0132] -- Dynamically modify the vertex position
[0133] for i,vertex in ipairs(mesh.vertices)do
[0134] vertex.x=vertex.x+speedX*deltaTime
[0135] vertex.y=vertex.y+speedY*deltaTime
[0136] end
[0137] end
[0138] -- Registration update listener, which implements the regular motion logic by listening to the motion frames of the virtual object. skeletonRenderer.state:addListener({
[0139] update = onUpdate
[0140] )
[0141] The above motion script information describes that the two-dimensional virtual object undergoes displacement in each deltaTime (which can represent the time interval for the virtual object to update its position, such as the time of one frame) according to the basic motion speeds of speedX and speedY.
[0142] In one implementation, the first motion information may further include random motion information. The above-mentioned controlling the vertices to move based on the basic motion speed in non-key frames may include the following steps:
[0143] In each non-key frame, generate the current random motion parameters according to the random motion information;
[0144] Based on the basic motion speed and the current random motion parameters, control the vertices to move.
[0145] Among them, the random motion information is used to add some randomness information during the regular motion process, making the motion of the vertices more complex and realistic. The random motion information represents the limiting conditions imposed on the randomness of the vertex motion, which can be set manually or determined by the system according to the scene of the virtual object. The current random motion parameters are random numbers generated under the restriction and guidance of the random motion information. For example, the random motion information may include: which motion parameters are randomized, the randomness range, etc. In one implementation, the random motion information may include the change range of the random motion parameters. In each non-key frame, the current random motion parameters can be randomly generated within this change range.
[0146] Based on the basic motion speed and the current random motion parameters, a motion control with a certain degree of randomness can be imposed on the vertices. Exemplarily, if it is determined to impose a random influence on the basic motion speed, the change range of the random motion speed coefficient can be set (such as -1 to 1). In each non-key frame, generate the random motion speed coefficient within the change range, multiply the basic motion speed by the random motion speed coefficient to obtain the random motion speed in the current frame, and control the vertices to move accordingly.
[0147] It can be seen that by introducing random motion information, the vertices have different motion conditions in different frames during the regular motion process, and the overall motion process has a certain degree of randomness, resulting in a more realistic dynamic effect.
[0148] The motion script information introducing random motion information can refer to the following code:
[0149] math.randomseed(os.time())
[0150] function onUpdate(deltaTime)
[0151] -- Obtain the current animation state and mesh
[0152] local animationState = skeletonRenderer.state
[0153] local mesh = skeleton.findSlot("yourMeshSlot").attachment
[0154] -- Dynamically modify the vertex positions
[0155] for i, vertex in ipairs(mesh.vertices) do
[0156] local randomX = math.random(-1, 1) # Set the change range of the random motion speed coefficient in the X direction
[0157] local randomY = math.random(-1, 1) # Set the change range of the random motion speed coefficient in the Y direction
[0158] vertex.x = vertex.x + randomX * speedX * deltaTime
[0159] vertex.y = vertex.y + randomY * speedY * deltaTime
[0160] end
[0161] end
[0162] -- Register the update listener
[0163] skeletonRenderer.state:addListener({
[0164] update = onUpdate
[0165] [[ID=3}}
[0166] In each non-key frame, a random motion speed coefficient is obtained. This coefficient is random. Multiply the random motion speed coefficient, the basic motion speed, and the time increment to obtain a first position change amount with randomness. Control the vertex to move according to the first position change amount. Thus, the vertex does not move at a constant speed in different non-key frames, and its motion speed is randomly affected, resulting in a random motion distance. Moreover, since the random motion speed coefficient may be negative, it is equivalent to changing the motion direction of the vertex, making the motion direction of the vertex also have a certain degree of randomness. Thereby increasing the irregularity of the virtual object's motion and enhancing the authenticity.
[0167] Step S320, in the key frame where a motion event occurs, determine the target position of the vertex based on the second motion information, and control the vertex to move to the target position.
[0168] Among them, the vertex moves according to the motion event in the key frame, and the target position represents the position of the vertex after movement in the motion event. Exemplarily, the second motion information may include a second position change amount, then add the initial position of the vertex in the key frame to the second position change amount to obtain the target position. Or, the second motion information may include the target position, then directly obtain the target position from the second motion information.
[0169] In one implementation manner, the motion control in the key frame can be realized through the logic code of the motion event. Specifically, the following code can be referred to:
[0170] -- Define an event listener
[0171] function onEvent(event)
[0172] if event.data.name == "moveVertex" then
[0173] local x = event.intValue["x"] or 0
[0174] local y = event.intValue["y"] or 0
[0175] -- Obtain the current animation state and mesh
[0176] local animationState = skeletonRenderer.state
[0177] local mesh = skeleton.findSlot("yourMeshSlot").attachment
[0178] -- Dynamically modify vertex positions
[0179] for i, vertex in ipairs(mesh.vertices) do
[0180] vertex.x = vertex.x + x
[0181] vertex.y = vertex.y + y
[0182] end
[0183] end
[0184] end
[0185] -- Register event listeners
[0186] skeletonRenderer.state:addListener({
[0187] event = onEvent
[0188] })
[0189] Among them, the event listener is used to listen for motion events. When a motion event is detected, the second motion information, such as the second position change amount, etc., is obtained from the information of the motion event. The target position is determined according to the second motion information, that is, the position of the vertex after movement in the motion event, and the vertex movement is controlled to the target position. It can be seen that in the motion event, the vertex does not move according to the conventional motion parameters, but performs a specified motion according to the second motion information, such as moving a specified distance (i.e., the second position change amount), or moving to a specified position (i.e., the target position).
[0190] Based on Figure 3 the method shown above, the vertices are respectively controlled to move in two motion modes at non-key frames and key frames. The processing method is relatively simple, and high-complexity motion results can be achieved, simulating the motion of flames, rivers, etc. in the real world.
[0191] It should be noted that one or more parameter setting controls can be provided through the user interface, so that developers can use the setting controls to set one or more of the above parameters, such as the basic motion speed, random motion information, the second position change amount, etc.
[0192] In one implementation, referring to Figure 4As shown, the above-mentioned obtaining the dynamic effect of the virtual object according to the movement of the vertices may include the following steps S410 and S420:
[0193] Step S410: According to the movement of the vertices, change the sampling information of the vertices in the texture map, or deform the displayed texture map to obtain the display images of the virtual object in multiple sequential frames;
[0194] Step S420: Generate an animation of the virtual object based on the display images of the virtual object in multiple sequential frames; the animation is used to present the dynamic effect of the virtual object.
[0195] Two dynamic implementation methods can be provided: One is to change the sampling information of the vertices in the texture map according to the movement of the vertices. That is, the vertices can be the above-mentioned bone points, change the corresponding coordinate points of the vertices in the texture map, and then change information such as the coloring of the vertices to achieve the dynamic change of the appearance of the virtual object. The other is to determine the change in the relative position of the vertices according to the movement of the vertices, and then deform the displayed texture map. For example, stretch or compress the grid in the texture map according to the change in the relative position of the vertices to achieve the dynamic change of the appearance of the virtual object. Multiple display images are obtained during the dynamic change process. Multiple sequential frames can be determined therefrom. For example, it can be selected by the art staff or automatically screened by the system, and the display images of different sequential frames are combined to generate the animation of the virtual object, or further normalized processing is performed on the basis of the combined sequential frames to obtain the final animation. This animation can present the dynamic effect of the virtual object.
[0196] The exemplary embodiment of the present disclosure also provides a virtual object processing device. Refer to Figure 5 As shown, the virtual object processing device 500 may include the following program modules:
[0197] A virtual object generation module 510, configured to perform grid processing on a target image to obtain a texture map, and generate a virtual object according to the texture map and a virtual model; the virtual object includes multiple vertices;
[0198] A first motion information determination module 520, configured to obtain first motion information of the vertices performing continuous motion within a preset time range;
[0199] A second motion information determination module 530, configured to determine second motion information of the vertices according to the motion event of the virtual object; the second motion information represents the motion information of the vertices in the motion event;
[0200] A motion control module 540, configured to control the vertices to move based on the first motion information and the second motion information, and obtain the dynamic effect of the virtual object according to the movement of the vertices.
[0201] In one embodiment, the virtual object processing device 500 may further include a target image generation module, configured to:
[0202] Obtain hint information for describing the target image;
[0203] Perform text-to-image processing on the hint information through a preset image generation model to obtain the target image.
[0204] In one embodiment, the generating a virtual object according to the texture map and the virtual model includes:
[0205] Determine the mapping relationship between the bone points of the virtual model and the texture map, and wrap the texture map around the surface of the virtual model according to the mapping relationship to form the virtual object; the vertices of the virtual object include the bone points and / or the grid points in the texture map.
[0206] In one embodiment, the vertices of the virtual object include the grid points; the obtaining first motion information of the vertices performing continuous motion within a preset time range includes:
[0207] Determine the weight information of the grid points, where the weight information includes the weights corresponding to one or more bone points bound to the grid points;
[0208] Obtain third motion information of the bone points performing continuous motion within the preset time range;
[0209] Weight the third motion information of the bone points bound to the grid points according to the weight information to obtain the first motion information of the grid points performing continuous motion within the preset time range.
[0210] In one embodiment, the determining the weight information of the grid points includes:
[0211] Determine the texture map position corresponding to the bone point according to the mapping relationship between the bone point and the texture map;
[0212] If the distance between the grid point and the texture map position corresponding to the bone point does not exceed a preset distance, bind the grid point and the bone point, and determine the weight corresponding to the bone point according to the distance, where the weight is negatively correlated with the distance.
[0213] In one embodiment, the first motion information includes a basic motion speed; the controlling the vertices to move based on the first motion information and the second motion information includes:
[0214] In non-critical frames where the motion event does not occur within the preset time range, control the vertices to move based on the basic motion speed;
[0215] At the key frame where the motion event occurs, determine the target position of the vertex based on the second motion information, and control the vertex to move to the target position.
[0216] In one implementation, for non-key frames where the motion event does not occur within the preset time range, controlling the vertex to move based on the basic motion speed includes:
[0217] In response to not detecting the motion event in the current frame, determine that the current frame is the non-key frame, and obtain the time increment between the current time and the time of the vertex's last movement;
[0218] Determine the first position change amount based on the basic motion speed and the time increment, and control the vertex to move according to the first position change amount.
[0219] In one implementation, the first motion information further includes random motion information;
[0220] For non-key frames where the motion event does not occur within the preset time range, controlling the vertex to move based on the basic motion speed includes:
[0221] In each non-key frame, generate current random motion parameters according to the random motion information;
[0222] Control the vertex to move based on the basic motion speed and the current random motion parameters.
[0223] In one implementation, obtaining the dynamic effect of the virtual object according to the movement of the vertex includes:
[0224] According to the movement of the vertex, change the sampling information of the vertex in the texture map, or deform the displayed texture map to obtain the display images of the virtual object in multiple sequential frames;
[0225] Generate an animation of the virtual object based on the display images of the virtual object in multiple sequential frames; the animation is used to present the dynamic effect of the virtual object.
[0226] The specific details of each part in the above device have been described in detail in the implementation manner of the method part. The undisclosed detailed content can be referred to the implementation manner content of the method part, and thus will not be elaborated here.
[0227] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the exemplary embodiments of the present disclosure, the features and functions of two or more of the above-described modules or units can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0228] The exemplary embodiments of the present disclosure also provide a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the above method is implemented.
[0229] In one embodiment, the computer program product may be a tangible product containing a computer program, such as a computer-readable storage medium storing the computer program. The readable storage medium may be a storage medium based on signals such as electricity, magnetism, light, electromagnetic, infrared, etc., including but not limited to: random access memory (RAM), read-only memory (ROM), magnetic tape, floppy disk, flash memory (Flash), mechanical hard disk (HDD), solid state drive (SSD), and so on. Exemplarily, the computer program product may be implemented as a non-volatile storage medium storing the computer program, such as read-only memory, NAND flash memory, etc.
[0230] In one embodiment, the computer program product may be an intangible product containing a computer program. Exemplarily, the computer program product may be implemented as a virtual digital product, such as an executable file storing the computer program, an installation package and other digital files.
[0231] The code of the computer program can be written in one or more programming languages. Programming languages such as C language, Java, C++, etc. The program code can be executed entirely on the user computing device, or partially on the user computing device, or executed as an independent software package, or partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, such as a local area network (LAN), a wide area network (WAN), etc., or can be connected to an external computing device (for example, through an Internet connection provided by an operator).
[0232] A computer program can be carried or transmitted by signals such as electricity, magnetism, light, electromagnetic, infrared, etc. An electronic device can convert the signal carrying the computer program into a digital signal and then run the computer program. When the computer program runs on the electronic device, its code is used to cause the electronic device to execute (more specifically, to cause the processor of the electronic device to execute) the method steps of various exemplary embodiments of the present disclosure. For example, the following steps can be executed: Step S110, perform a grid processing on a target image to obtain a texture map, and generate a virtual object according to the texture map and a virtual model; the virtual object includes a plurality of vertices; Step S120, obtain first motion information of the vertices performing continuous motion within a preset time range; Step S130, determine second motion information of the vertices according to the motion events of the virtual object; the second motion information represents the motion information of the vertices in the motion events; Step S140, control the vertices to move based on the first motion information and the second motion information, and obtain a dynamic effect of the virtual object according to the motion of the vertices.
[0233] Implementing the above method steps through a computer program, performing a grid processing on a target image to obtain a texture map, combining the texture map with a virtual model to generate a virtual object, for the vertices of the virtual object, obtaining the first motion information of its continuous motion, and determining the second motion information according to the motion events of the virtual object, controlling the vertices to move based on the first motion information and the second motion information, and the motion of the vertices brings about changes in display effects such as the texture map, thereby forming a dynamic effect of the virtual object. It can be seen that the present solution provides a method for automatically generating a virtual dynamic effect, which can achieve the dynamic effect of a virtual object without relying on manually drawn materials, reducing the human and time costs. Moreover, by using the first motion information of continuous motion and the second motion information in the case of a motion event, controlling the vertices to perform the combination of two motions improves the complexity of the vertex motion, making the dynamic effect based on the vertex motion more complex and realistic, which is beneficial to achieving a high-quality dynamic effect.
[0234] An exemplary embodiment of the present disclosure further provides an electronic device. The electronic device may include a processor and a memory. The memory stores executable instructions of the processor, which may be a computer program. The processor executes the executable instructions to execute the method steps of various exemplary embodiments of the present disclosure.
[0235] Next, with reference to Figure 6 , an electronic device will be exemplarily described in the form of a general computing device. It should be understood that Figure 6 the electronic device 600 shown is only an example, and should not impose limitations on the functions and usage scopes of the embodiments of the present disclosure.
[0236] Such as Figure 6As shown, the electronic device 600 may include: a processor 610, a memory 620, a bus 630, an I / O (input / output) interface 640, and a network adapter 650.
[0237] The memory 620 may include volatile memory, such as RAM 621 and a cache unit 622, and may also include non-volatile memory, such as ROM 623. The memory 620 may further include one or more program modules 624. Such program modules 624 include, but are not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include the implementation of a network environment. For example, the program module 624 may include each module in the above device.
[0238] The processor 610 may include one or more processing units. For example, the processor 610 may include a processing unit such as an AP (Application Processor), a modem processor, a GPU, an ISP (Image Signal Processor), a controller, an encoder, a decoder, a DSP (Digital Signal Processor), a baseband processor, and / or an NPU (Neural-Network Processing Unit).
[0239] The processor 610 can be used to execute executable instructions stored in the memory 620. For example, it can execute the following steps: Step S110, perform meshing on the target image to obtain a texture map, and generate a virtual object based on the texture map and the virtual model; the virtual object includes multiple vertices; Step S120, obtain first motion information of the vertices moving continuously within a preset time range; Step S130, determine second motion information of the vertices according to the motion event of the virtual object; the second motion information represents the motion information of the vertices in the motion event; Step S140, control the vertices to move based on the first motion information and the second motion information, and obtain the dynamic effect of the virtual object according to the motion of the vertices.
[0240] By executing the above method steps through the processor 610, the target image is meshed to obtain a texture map, the texture map is combined with the virtual model to generate a virtual object. For the vertices of the virtual object, the first motion information of its continuous motion is obtained, and the second motion information is determined according to the motion events of the virtual object. Based on the first motion information and the second motion information, the vertices are controlled to move. The movement of the vertices brings changes in display effects such as the texture map, thereby forming the dynamic effect of the virtual object. It can be seen that this solution provides a method for automatically generating virtual dynamic effects, which can achieve the dynamic effects of virtual objects without relying on manually drawn materials, reducing labor and time costs. Moreover, by using the first motion information of continuous motion and the second motion information in the case of motion events, the combination of two motions is controlled for the vertices, improving the complexity of the vertex motion and making the dynamic effects based on the vertex motion more complex and realistic, which is beneficial to achieving high-quality dynamic effects.
[0241] The bus 630 is used to implement the connection between different components of the electronic device 600 and may include a data bus, an address bus, and a control bus.
[0242] The electronic device 600 can communicate with one or more external devices 700 (such as a keyboard, a mouse, an external controller, etc.) through the I / O interface 640.
[0243] The electronic device 600 can communicate with one or more networks through the network adapter 650. For example, the network adapter 650 can provide mobile communication solutions such as 3G / 4G / 5G, or provide wireless communication solutions such as wireless local area network, Bluetooth, and near field communication. The network adapter 650 can communicate with other modules of the electronic device 600 through the bus 630.
[0244] Although Figure 6 not shown in the figure, other hardware and / or software modules can also be set in the electronic device 600, including but not limited to: a display, microcode, a device driver, a redundant processor, an external disk drive array, a tape drive, and a data backup storage system, etc.
[0245] As can be seen from the above, the technical solution of the present disclosure can be implemented as a method, a device, a system, a computer program product, a storage medium, an electronic device, etc. Those skilled in the art can understand that various aspects of the present disclosure can be specifically implemented in the following forms, namely: a complete hardware implementation manner, a complete software implementation manner (including firmware, microcode, etc.), or an implementation manner combining hardware and software aspects, which can be respectively referred to as "circuit", "module", or "system".
[0246] It should be understood that the present disclosure is not limited to the specific method steps or structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. Those skilled in the art will readily think of other embodiments based on the specific embodiments provided by the present disclosure. Therefore, the specific embodiments provided by the present disclosure are only exemplary, and the scope and spirit of the present disclosure are pointed out by the claims, and should cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include the common general knowledge or conventional technical means in the technical field not disclosed by the present disclosure.
Claims
1. A virtual object processing method, characterized in that: The method comprises: Performing mesh processing on the target image to obtain a map, and generating a virtual object according to the map and the virtual model; the virtual object includes a plurality of vertices; Acquire first motion information of the vertex performing continuous motion within a preset time range; Determine second motion information of the vertex according to the motion event of the virtual object; the second motion information represents the motion information of the vertex in the motion event; The vertex is controlled to move based on the first motion information and the second motion information, and a dynamic effect of the virtual object is obtained according to the movement of the vertex.
2. The method according to claim 1, characterized in that The method further comprises: Acquire prompt information for describing the target image; The prompt information is processed by a preset image generation model to obtain the target image.
3. The method according to claim 1, characterized in that The step of generating a virtual object according to the map and the virtual model comprises: Determine a mapping relationship between the skeleton points of the virtual model and the map, and cover the surface of the virtual model with the map according to the mapping relationship to form the virtual object; the vertices of the virtual object include the skeleton points and / or the grid points in the map.
4. The method according to claim 3, characterized in that: The vertices of the virtual object include the grid points; and obtaining first motion information of the vertices that continuously move within a preset time range includes: Determine weight information of the grid point, the weight information including weights corresponding to one or more skeleton points bound to the grid point; Acquire third motion information of the skeleton point performing continuous motion within the preset time range; The third motion information of the skeleton point bound to the grid point is weighted according to the weight information to obtain the first motion information of the grid point that continuously moves within the preset time range.
5. The method according to claim 4, characterized in that The determining the weight information of the grid points includes: Determine the mapping position corresponding to the skeleton point according to the mapping relationship between the skeleton point and the map; If the distance between the mapping positions corresponding to the grid point and the skeleton point does not exceed a preset distance, the grid point and the skeleton point are bound, and a weight corresponding to the skeleton point is determined according to the distance, and the weight is negatively correlated with the distance.
6. The method according to claim 1, characterized in that The first motion information includes a basic motion speed; and controlling the vertex to move based on the first motion information and the second motion information includes: In a non-key frame where the motion event does not occur within the preset time range, controlling the vertex to move based on the basic motion speed; At a key frame where the motion event occurs, a target position of the vertex is determined based on the second motion information, and the vertex is controlled to move to the target position.
7. The method according to claim 6, characterized in that The non-key frame in which the motion event does not occur within the preset time range, controlling the vertex to move based on the basic motion speed, comprises: In response to not monitoring the motion event in the current frame, determining that the current frame is the non-key frame, and obtaining a time increment between the current time and the time when the vertex last moved; A first position change is determined based on the basic movement speed and the time increment, and the vertex is controlled to move according to the first position change.
8. The method according to claim 6, characterized in that The first motion information further includes random motion information; the non-key frame in which the motion event does not occur within the preset time range, controlling the vertex to move based on the basic motion speed, includes: In each of the non-key frames, generating current random motion parameters according to the random motion information; The vertex is controlled to move based on the basic motion speed and the current random motion parameter.
9. The method according to any one of claims 1 to 8, characterized in that: The step of obtaining the dynamic effect of the virtual object according to the movement of the vertex comprises: According to the movement of the vertex, the sampling information of the vertex in the map is changed, or the displayed map is deformed to obtain the display screen of the virtual object in multiple sequence frames; An animation of the virtual object is generated based on display images of the virtual object in multiple sequence frames; the animation is used to present a dynamic effect of the virtual object.
10. A virtual object processing device, characterized in that: The device comprises: A virtual object generation module is configured to perform meshing processing on the target image to obtain a texture, and generate a virtual object according to the texture and the virtual model; the virtual object includes a plurality of vertices; A first motion information determining module is configured to obtain first motion information of the vertex that continuously moves within a preset time range; A second motion information determination module is configured to determine second motion information of the vertex according to the motion event of the virtual object; the second motion information represents the motion information of the vertex in the motion event; The motion control module is configured to control the vertex to move based on the first motion information and the second motion information, and obtain a dynamic effect of the virtual object according to the movement of the vertex.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
12. An electronic device, characterized in that: include: processor; A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 9 by executing the executable instructions.