Control method and device of voxel model and electronic equipment
By generating voxel models based on the target model and creating a constraint relationship between hair follicles and voxel units at the voxel unit position, the problem of low voxel animation production efficiency in the existing technology is solved, and the matching of the dynamic changes of voxel models and the dynamic changes of the target model is achieved, and the production efficiency is improved.
Patent Information
- Application Number
- CN202411730116.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-05-02
AI Technical Summary
In the prior art, voxel models and bone skins are required to be generated when creating voxel animations, which are difficult and time-consuming, resulting in low efficiency in voxel animation production.
By generating a voxel model based on the target model, the shape of the voxel model matches the target model, including multiple voxel units, and the voxel units are pre-equipped with corresponding model positions on the target model. Create hair follicles at the model location corresponding to the voxel unit, and set the constraint relationship between the hair follicles and voxel units to control the target model for dynamic changes to control voxel unit changes based on the constraint relationship through the hair follicles.
The dynamic changes of the voxel model are matched with the dynamic changes of the target model, and the operation is simple and convenient, which improves the production efficiency of voxel animation.
Smart Images

Figure CN119919546A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a voxel model control method, device and electronic equipment. Background Art
[0002] In the related technology, when making voxel animation, it is necessary to first generate a voxel model, then create a skeleton skin, and drive the voxel model through the skeleton skin to achieve the dynamic change effect of the voxel model; since the operation of creating a skeleton skin is difficult and time-consuming, the efficiency of voxel animation production is low. Summary of the invention
[0003] In view of this, an object of the present invention is to provide a voxel model control method, device and electronic device to improve the production efficiency of voxel animation.
[0004] In a first aspect, an embodiment of the present invention provides a method for controlling a voxel model, the method comprising: generating a voxel model based on a target model; wherein the shape of the voxel model matches the shape of the target model; the voxel model comprises a plurality of voxel units; the voxel units are preset with corresponding model positions on the target model; hair follicles are created at the model positions corresponding to the voxel units, and a constraint relationship between the hair follicles and the voxel units is set; wherein the hair follicles are attached to the model positions of the target model; and the target model is controlled to change dynamically, so as to control the change of the voxel units based on the constraint relationship through the hair follicles, so that the dynamic change of the voxel model matches the dynamic change of the target model.
[0005] In a second aspect, an embodiment of the present invention further provides a control device for a voxel model, the device comprising: a voxel model generation module, for generating a voxel model based on a target model; wherein the shape of the voxel model matches the shape of the target model; the voxel model comprises a plurality of voxel units; the voxel units are preset with corresponding model positions on the target model; a constraint relationship setting module, for creating hair follicles at the model positions corresponding to the voxel units, and setting the constraint relationship between the hair follicles and the voxel units; wherein the hair follicles are attached to the model positions of the target model; a dynamic change control module, for controlling the target model to change dynamically, so as to control the change of the voxel units based on the constraint relationship through the hair follicles, so that the dynamic change of the voxel model matches the dynamic change of the target model.
[0006] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the above-mentioned voxel model control method.
[0007] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned voxel model control method.
[0008] The embodiments of the present invention bring the following beneficial effects:
[0009] The control method, device and electronic device of the voxel model described above generate a voxel model based on a target model; wherein the shape of the voxel model matches the shape of the target model; the voxel model includes a plurality of voxel units; the voxel units are preset with corresponding model positions on the target model; hair follicles are created at the model positions corresponding to the voxel units, and a constraint relationship between the hair follicles and the voxel units is set; wherein the hair follicles are attached to the model positions of the target model; the target model is controlled to change dynamically, so as to control the change of the voxel units based on the constraint relationship through the hair follicles, so that the dynamic change of the voxel model matches the dynamic change of the target model. In this method, a voxel model including a plurality of voxel units is generated according to the target model, hair follicles are created at the model positions of the target model corresponding to the voxel units, and a constraint relationship is set between the hair follicles and the voxel units. When the target model changes dynamically, the hair follicles at the model positions control the voxel units to change dynamically at the same time through the constraint relationship. This method realizes the dynamic change of the voxel model following the target model through the hair follicles, is simple and convenient to operate, and improves the production efficiency of voxel animation.
[0010] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.
[0011] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0013] Figure 1 A flow chart of a voxel model control method provided by an embodiment of the present invention;
[0014] Figure 2A schematic diagram of a bounding box and emitting rays from a ray starting point on a specified plane provided by an embodiment of the present invention;
[0015] Figure 3 A schematic diagram of emitting a ray from a ray starting point on the left plane of a bounding box provided by an embodiment of the present invention;
[0016] Figure 4 A schematic diagram of generating a voxel unit provided by an embodiment of the present invention;
[0017] Figure 5 A schematic diagram of obtaining color values from map data provided by an embodiment of the present invention;
[0018] Figure 6 A schematic diagram of a voxel unit for rendering a voxel model provided by an embodiment of the present invention;
[0019] Figure 7 A schematic diagram of a voxel model control device provided by an embodiment of the present invention;
[0020] Figure 8 A structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0022] For ease of understanding, some terms involved in the present invention are explained below:
[0023] Voxel: A basic unit in three-dimensional space. Voxel is short for Volume Element. Each voxel has a length, width, and height, which are used to describe its position and size in three-dimensional space, and each voxel can store some information, such as color, density, or material properties. In computer graphics, voxels usually represent grids in three-dimensional models, where each voxel represents a small cube; these cubes can be used to build complex three-dimensional shapes.
[0024] In the related art, when making voxel animations, such as animations of hollow voxels or surface voxels, it is necessary to first generate a voxel model, then execute the steps of creating a skeleton skin and assigning weights to the bones, and drive the voxel model through the skeleton skin, so as to achieve the dynamic change effect of the voxel model. However, this method is difficult to create a skeleton skin and is time-consuming, resulting in low efficiency in voxel animation production. In addition, it is currently difficult for producers to accurately locate the color value corresponding to each voxel, and usually the color value of the voxel needs to be set manually, which consumes a lot of time and effort.
[0025] Based on this, a voxel model control method, device and electronic device provided by an embodiment of the present invention can be applied to making voxel animation.
[0026] To facilitate understanding of this embodiment, a control method of a voxel model disclosed in an embodiment of the present invention is first described in detail. Figure 1 As shown, the method comprises the following steps:
[0027] Step S102, generating a voxel model based on the target model; wherein the shape of the voxel model matches the shape of the target model; the voxel model includes a plurality of voxel units; and the voxel units are preset with corresponding model positions on the target model;
[0028] Specifically, first, a cubic bounding box is generated according to the target model, and each side of the bounding box is parallel to the coordinate axis of the world coordinate system, so that the bounding box can enclose the target model and the bounding box is of minimum size, wherein the world coordinate system is the absolute coordinate system of the system, which can describe the position of the object. In actual implementation, the position of each point of the target model in the world coordinate system can be traversed, and the maximum and minimum values of these positions on the x-axis, y-axis and z-axis can be obtained, so as to generate the most accurate bounding box for the target model, and the cube is evenly filled inside the bounding box. The cube is used as a standard voxel, and the standard position of each standard voxel is calculated. Then, the calculated data results can be recorded in a list for storage.
[0029] Next, determine the designated plane of the bounding box, which usually includes three planes, any two of which are connected to each other and have a vertical relationship, such as the left plane, the back plane and the bottom plane of the bounding box; then determine the standard voxels distributed on the designated plane from multiple standard voxels, and determine them as edge voxels. The position of the ray starting point for emitting rays into the bounding box is determined based on the edge voxels. For example, if the designated plane is the left plane, the ray starting point can be the position of the voxel point closest to the origin of the world coordinate system among the edge voxels located on the left plane, or the edge area can be evenly divided into the edge areas of the left plane according to the edge voxels located on the left plane, and the center point of each edge area is determined as the position of the ray starting point.
[0030] After determining the position of the ray starting point, a ray is emitted from each ray starting point into the bounding box to perform collision detection with the target model. The ray is perpendicular to the specified plane where the ray starting point is located, and the ray direction can be along the positive direction of the x-axis, y-axis, and z-axis of the world coordinate system. On the target model, the position of the collision point in the world coordinate system generated when the ray collides with the target model is obtained, which is referred to as the world position below. The generated collision point may be one or more. Here, the three-dimensional world position of the collision point is converted into a two-dimensional mapping coordinate mapped to the collision point in the mapping data of the target model. Then, a voxel unit is generated according to the world position of the collision point. For example, the target standard position closest to the world position of the collision point can be obtained from the list of standard positions of the bounding box, and a voxel unit is generated at the target standard position. It should be noted that if there are repeated target standard positions, only one target standard position can be retained.
[0031] The voxel model is composed of voxel units, wherein the voxel units are preset with corresponding model positions on the target model, and the information of the voxel units can be associated with the information of the model positions; the shape of the voxel model matches the shape of the target model, that is, the voxel model and the target model have similar appearances, but the target model has a smoother appearance than the voxel model. The larger the volume of the voxel unit, the stronger the block feeling; and the smaller the volume of the voxel unit, the stronger the granular feeling.
[0032] In the above method, a voxel model composed of a plurality of voxel units corresponding to the model position is generated according to the target model.
[0033] Step S104, creating a hair follicle at the model position corresponding to the voxel unit, and setting a constraint relationship between the hair follicle and the voxel unit; wherein the hair follicle is attached to the model position of the target model;
[0034] The constraint relationship may be a parent-child constraint relationship, where the hair follicle attached to the model position of the target model is taken as the parent, and the voxel unit having a constraint relationship with the hair follicle is taken as the child. The target model may indirectly affect the voxel unit through the hair follicle at the model position.
[0035] Specifically, after creating a hair follicle on the model position surface corresponding to the voxel unit, a constraint relationship between the hair follicle and the voxel unit is set; the mapping coordinates of the collision point are set to the mapping coordinates of the hair follicle to determine the position of the hair follicle, and then the voxel unit is constrained. At this time, the position of each hair follicle is the same as or close to the position of the corresponding voxel unit.
[0036] Here, the mapping data of the target model can be obtained according to the path information of the mapping data stored in the system, such as the color map, transparency map, etc. in the texture map, and then the mapping coordinates of the hair follicles can be mapped to the mapping data, and the rendering parameters can be obtained from the mapping data. The voxel units corresponding to the hair follicles are rendered using the rendering parameters. For example, the color value obtained in the color map is assigned to the material color of the corresponding voxel unit to obtain the rendering effect of the voxel model.
[0037] In the above method, a hair follicle is created at a model position corresponding to a voxel unit, a constraint relationship between the hair follicle and the voxel unit is constructed, and the target model and the voxel model are connected through the hair follicle.
[0038] Step S106, controlling the target model to change dynamically, so as to control the change of the voxel unit based on the constraint relationship through the hair follicles, so that the dynamic change of the voxel model matches the dynamic change of the target model.
[0039] Specifically, when the target model undergoes dynamic changes, such as a displacement transformation or a morphological transformation in the target model in the animation, the hair follicles at the model position of the target model will change accordingly. Through the constraint relationship between the hair follicles and the voxel units, the voxel units and the model position are controlled to produce the same dynamic transformation, so that the dynamic changes of the voxel model match the dynamic changes of the target model. At this time, the animation effect of the voxel model can be achieved.
[0040] The control method of the voxel model is as follows: a voxel model is generated based on a target model; wherein the shape of the voxel model matches the shape of the target model; the voxel model includes a plurality of voxel units; the voxel units are preset with corresponding model positions on the target model; hair follicles are created at the model positions corresponding to the voxel units, and a constraint relationship between the hair follicles and the voxel units is set; wherein the hair follicles are attached to the model positions of the target model; the target model is controlled to change dynamically, so as to control the change of the voxel units based on the constraint relationship through the hair follicles, so that the dynamic change of the voxel model matches the dynamic change of the target model. In this method, a voxel model including a plurality of voxel units is generated according to the target model, a hair follicle is created at the model position of the target model corresponding to the voxel unit, and a constraint relationship is set between the hair follicles and the voxel units. When the target model changes dynamically, the hair follicles at the model position control the voxel units to change dynamically at the same time through the constraint relationship. This method realizes the dynamic change of the voxel model following the target model through the hair follicles, is simple and convenient to operate, and improves the production efficiency of voxel animation.
[0041] The following embodiments provide specific implementation methods for generating voxel models.
[0042] Specifically, a bounding box is generated to surround the target model, and a plurality of standard voxels are generated within the bounding box; edge voxels located on a specified plane of the bounding box are determined from the plurality of standard voxels, and a ray starting point is determined based on the edge voxels; a ray is emitted from the ray starting point to the inside of the bounding box, and a collision point where the ray collides with the target model is obtained on the target model; based on the collision point, voxel units constituting the voxel model are generated.
[0043] The standard voxel usually refers to the voxel filled in the bounding box, and the standard voxel here can be set on the surface of the target model; the edge voxel usually refers to the voxel distributed on the six orientation planes of the front, back, left, right, top and bottom of the bounding box.
[0044] First, a cubic bounding box is generated that can enclose the target model. The bounding box can be understood as a virtual BBX (Bounding Box). Each side of the bounding box is parallel to the coordinate axis of the world coordinate system, so that the bounding box can enclose the target model and the bounding box is of the minimum size. For example, the positive directions of the three coordinate axes of the world coordinate system are as follows: Figure 2 As shown, in actual implementation, the position of each model position of the target model can be traversed to obtain the maximum and minimum values of these positions on the x-axis, y-axis and z-axis, so as to generate the most accurate bounding box for the target model, and fill the voxel cube evenly inside the bounding box. The cube is used as a standard voxel, and the standard position is calculated for each standard voxel. Then the calculated data results can be recorded in a list for storage; here the user can customize the size of the voxel unit by setting the size of the standard voxel.
[0045] Next, the designated plane of the bounding box is determined, and the standard voxels located on the designated plane are determined from the multiple standard voxels, and are determined as edge voxels; Figure 3 As shown, taking the designated plane as the left plane as an example, the left plane is evenly divided into edge regions according to the edge voxels located on the left plane, and the center point of each edge region is determined as the position of the ray starting point. Figure 3 In the figure, a ray is emitted from each ray starting point into the bounding box. The ray is perpendicular to the left plane where the ray starting point is located, and the ray direction is the positive direction of the x-axis of the world coordinate system. The same applies to rays in other planes.
[0046] Each ray is collided with the target model, and the world position of the collision point between the ray and the target model is obtained on the target model. If the ray is just tangent to the target model, the ray generates one collision point; if the ray penetrates the model, the ray generates two, three, or four collision points. Then, voxel units are generated according to the world position of the collision point, and the voxel model is composed of voxel units. In an example, Figure 4As shown in (a), if voxel units are generated at the world position of the collision point, then the voxel units will cross and be arranged unevenly; or, Figure 4 As shown in (b), the target standard position closest to the world position of the collision point can be obtained from the list of standard positions of the bounding box, and a voxel unit is generated at the target standard position. At this time, the voxel units are evenly arranged. It should be noted that if there are repeated target standard positions, only one target standard position can be retained.
[0047] In this embodiment, each side of the bounding box is parallel to a coordinate axis in the world coordinate system. The same is applicable to the case where the target model is in an inclined state, which will not be described in detail here.
[0048] In the above method, the starting point of the ray is determined according to the specified plane of the bounding box, the collision point with the target model is obtained by performing collision detection between the emitted ray and the target model, and then voxel units constituting the voxel model are generated on the surface of the target model according to the collision point.
[0049] Furthermore, the bounding box is uniformly filled with preset standard voxels until the bounding box is filled with standard voxels.
[0050] Here, the volume size of the standard voxel can be preset, and the standard voxel is usually a cube; the preset standard voxels are used to evenly fill the inside of the bounding box until the inside of the bounding box is filled with standard voxels; the user can customize the size of the voxel unit by setting the size of the standard voxel.
[0051] In one approach, the standard position of the standard voxel within the bounding box is recorded.
[0052] Here, the standard position of each standard voxel in the bounding box is calculated, and the calculated standard position of each standard voxel is recorded in a list for storage.
[0053] Specifically, the above-mentioned designated planes include three planes, any two of which are connected to each other and perpendicular to each other; for example, the left side plane, the rear side plane and the bottom side plane of the bounding box.
[0054] In one method, the target voxel position on the edge voxel that is closest to the specified plane is determined as the starting point of the ray.
[0055] For example, set the specified planes to the left plane, the back plane, and the bottom plane, such as Figure 2 As shown, the starting point of the ray is the target voxel position on the edge voxel closest to the specified plane. Figure 2 In the figure, a target voxel position in each plane is used as an example to show the ray starting point and ray direction. Figure 2Taking the left plane in the figure as an example, the value of each ray starting point on the x-axis in the world coordinate system is min(x), the value on the y-axis is the result of the product of m and the height of each edge voxel and the sum of min(y), and the value on the z-axis is the result of the product of n and the width of each edge voxel and the sum of min(z); wherein min(x) represents the minimum value of the bounding box on the x-axis, min(y) represents the minimum value of the bounding box on the y-axis, min(z) represents the minimum value of the bounding box on the z-axis, m represents the edge voxel on the m-th y-axis, and n represents the edge voxel on the n-th z-axis. The same applies to the case where the specified plane is the back plane and the bottom plane, which will not be repeated here.
[0056] In one method, a target standard voxel closest to the collision point is obtained from the standard voxels in the bounding box, and the target standard voxel is used as a voxel unit constituting the voxel model.
[0057] A list of standard positions of the standard voxels recorded above can be obtained, the world position of the collision point is compared with the standard positions in the list, and then a target standard position closest to the collision point is obtained from the list, and the target standard voxel located at the target standard position in the bounding box is used as the voxel unit constituting the voxel model.
[0058] The following embodiments provide specific implementations of rendering voxel models.
[0059] Specifically, the texture data of the target model is obtained; the rendering parameters of the model position are obtained from the texture data through the hair follicles; and the voxel units corresponding to the hair follicles are rendered using the rendering parameters.
[0060] Here, the texture data of the target model, such as color map, transparency map, normal map, environment map and noise map, can be obtained according to the path information of the texture data stored in the system of the target model. By adjusting the parameters of the texture data, the rendering effect of the voxel model can be controlled. Through the image processing library of the Python programming language, the UV texture value of the model position of the hair follicle of the target model is mapped to the texture data, and the rendering parameters are obtained from the texture data. For example, when the texture data is a color map, such as Figure 5 In , the UV map value of the model position where the hair follicle is located is mapped to the color map to obtain the color value.
[0061] Next, the voxel units corresponding to the hair follicles are rendered using the obtained rendering parameters, thereby controlling the appearance and behavior of the voxel model. For example, the voxel model composed of voxel units is as follows: Figure 6 As shown in (a), after obtaining the color value, the color value obtained in the color map is assigned to the material color of the corresponding voxel unit, such as Figure 6As shown in (b), the rendering effect of the voxel model is obtained.
[0062] Optionally, different rendering effects are obtained by rendering the voxel units corresponding to the hair follicles using different rendering parameters. For example, the voxel units corresponding to the hair follicles are rendered using parameters such as light color and light intensity to obtain lighting effects; or, the voxel units corresponding to the hair follicles are rendered using parameters such as diffuse reflection, specular reflection, transparency, refractive index, etc. to obtain material effects such as glass, metal, and plastic.
[0063] In the above method, by obtaining the rendering parameters of the model position from the map data through the hair follicles, the voxel unit corresponding to the model position can be accurately rendered, so that the rendering effect of each voxel unit is consistent with the rendering parameters of the model position in the map data.
[0064] In one method, a collision point corresponding to a voxel unit is obtained, and the mapping coordinates corresponding to the collision point are set as the mapping coordinates of the hair follicle; and rendering parameters are obtained from the mapping data based on the mapping coordinates of the hair follicle.
[0065] After obtaining the collision point corresponding to the voxel unit, the three-dimensional world position of the collision point is converted into a two-dimensional texture coordinate of the collision point mapped in the texture data of the target model, and the texture coordinate is set as the texture coordinate of the hair follicle to determine the position of the hair follicle. At this time, the position of each hair follicle is the same as or close to the position of the corresponding voxel unit; then the texture coordinate of the hair follicle is mapped on at least one texture data, and rendering parameters are obtained from the at least one texture data. The rendering parameters can specifically be parameters such as color, transparency, diffuse reflection, specular reflection and refractive index.
[0066] The above-mentioned embodiments of the present application can quickly realize the animation effect of the voxel model, efficiently and accurately render the voxel units, and obtain the proper rendering effect of each voxel unit, thereby improving the realism and visual quality of the voxel model and greatly reducing the production difficulty.
[0067] For the above method embodiments, see Figure 7 A schematic diagram of a control device for a voxel model shown; the device comprises:
[0068] The voxel model generation module 701 is used to generate a voxel model based on the target model; wherein the shape of the voxel model matches the shape of the target model; the voxel model includes a plurality of voxel units; and the voxel units are preset with corresponding model positions on the target model;
[0069] The constraint relationship setting module 702 is used to create a hair follicle at the model position corresponding to the voxel unit and set the constraint relationship between the hair follicle and the voxel unit; wherein the hair follicle is attached to the model position of the target model;
[0070] The dynamic change control module 703 is used to control the target model to change dynamically, so as to control the change of voxel units based on the constraint relationship through the hair follicles, so that the dynamic change of the voxel model matches the dynamic change of the target model.
[0071] The control device of the voxel model generates a voxel model based on a target model; wherein the shape of the voxel model matches the shape of the target model; the voxel model includes a plurality of voxel units; the voxel units are preset with corresponding model positions on the target model; hair follicles are created at the model positions corresponding to the voxel units, and a constraint relationship between the hair follicles and the voxel units is set; wherein the hair follicles are attached to the model positions of the target model; the target model is controlled to change dynamically, so as to control the change of the voxel units based on the constraint relationship through the hair follicles, so that the dynamic change of the voxel model matches the dynamic change of the target model. In this method, a voxel model including a plurality of voxel units is generated according to the target model, hair follicles are created at the model positions of the target model corresponding to the voxel units, and a constraint relationship is set between the hair follicles and the voxel units. When the target model changes dynamically, the hair follicles at the model positions control the voxel units to change dynamically at the same time through the constraint relationship. This method realizes the dynamic change of the voxel model following the target model through the hair follicles, is simple and convenient to operate, and improves the production efficiency of voxel animation.
[0072] The above-mentioned voxel model generation module is also used to generate a bounding box surrounding the target model, generate multiple standard voxels in the bounding box; determine the edge voxels located on the specified plane of the bounding box from the multiple standard voxels, and determine the starting point of the ray based on the edge voxels; emit rays from the starting point of the ray to the inside of the bounding box, and obtain the collision point where the ray collides with the target model on the target model; based on the collision point, generate the voxel units that constitute the voxel model.
[0073] The voxel model generation module is further used to uniformly fill the bounding box with preset standard voxels until the bounding box is fully filled with standard voxels.
[0074] The above device also includes a standard position recording module, which is used to record the standard position of the standard voxel in the bounding box.
[0075] The above-mentioned designated planes include three planes, and any two of the three planes are connected to each other and are perpendicular to each other.
[0076] The voxel model generation module is also used to determine the target voxel position on the edge voxel that is closest to the designated plane as the starting point of the ray.
[0077] The voxel model generation module is also used to obtain the target standard voxel closest to the collision point from the standard voxels in the bounding box, and use the target standard voxel as the voxel unit constituting the voxel model.
[0078] The above device also includes a voxel unit rendering module, which is used to obtain the map data of the target model; obtain the rendering parameters of the model position from the map data through the hair follicles; and use the rendering parameters to render the voxel units corresponding to the hair follicles.
[0079] The voxel unit rendering module is further used to obtain the collision point corresponding to the voxel unit, set the mapping coordinates corresponding to the collision point as the mapping coordinates of the hair follicle; and obtain rendering parameters from the mapping data based on the mapping coordinates of the hair follicle.
[0080] This embodiment also provides an electronic device, including a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the above-mentioned voxel model control method. The electronic device can be a server or a terminal device.
[0081] See also Figure 8 As shown, the electronic device includes a processor 100 and a memory 101. The memory 101 stores computer executable instructions that can be executed by the processor 100. The processor 100 executes the computer executable instructions to implement the above-mentioned voxel model control method.
[0082] Further, Figure 8 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 100 , the communication interface 103 and the memory 101 are connected via the bus 102 .
[0083] The memory 101 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0084] The processor 100 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 100. The above processor 100 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101 and completes the steps of the method of the above embodiment in combination with its hardware.
[0085] The processor in the above electronic device can implement the following operations in the above voxel model control method by executing computer executable instructions:
[0086] A voxel model is generated based on a target model; wherein the shape of the voxel model matches the shape of the target model; the voxel model includes a plurality of voxel units; the voxel units are preset with corresponding model positions on the target model; hair follicles are created at the model positions corresponding to the voxel units, and a constraint relationship between the hair follicles and the voxel units is set; wherein the hair follicles are attached to the model positions of the target model; the target model is controlled to change dynamically, so as to control the change of the voxel units based on the constraint relationship through the hair follicles, so that the dynamic change of the voxel model matches the dynamic change of the target model.
[0087] Generate a bounding box that surrounds the target model, and generate multiple standard voxels in the bounding box; determine the edge voxels located on the specified plane of the bounding box from the multiple standard voxels, and determine the starting point of the ray based on the edge voxels; emit rays from the starting point of the ray into the bounding box, and obtain the collision point where the ray collides with the target model on the target model; based on the collision point, generate voxel units that constitute the voxel model.
[0088] Use the preset standard voxels to uniformly fill the bounding box until the bounding box is filled with standard voxels.
[0089] Record the standard position of the standard voxel in the bounding box.
[0090] The above-mentioned designated planes include three planes, and any two of the three planes are connected to each other and are perpendicular to each other.
[0091] The target voxel position on the edge voxel that is closest to the specified plane is determined as the starting point of the ray.
[0092] From the standard voxels in the bounding box, the target standard voxel closest to the collision point is obtained, and the target standard voxel is used as the voxel unit constituting the voxel model.
[0093] The texture data of the target model is obtained; the rendering parameters of the model position are obtained from the texture data through the hair follicles; and the voxel units corresponding to the hair follicles are rendered using the rendering parameters.
[0094] The collision point corresponding to the voxel unit is obtained, and the mapping coordinates corresponding to the collision point are set as the mapping coordinates of the hair follicle; based on the mapping coordinates of the hair follicle, the rendering parameters are obtained from the mapping data.
[0095] In the above method, a voxel model including multiple voxel units is generated according to the target model, hair follicles are created at the model position of the target model corresponding to the voxel units, and a constraint relationship is set between the hair follicles and the voxel units. When the target model changes dynamically, the hair follicles at the model position control the voxel units to change dynamically at the same time through the constraint relationship. This method enables the voxel model to follow the dynamic changes of the target model through the hair follicles. The operation is simple and convenient, which improves the production efficiency of voxel animation.
[0096] This embodiment also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned voxel model control method.
[0097] The computer executable instructions stored in the computer readable storage medium can implement the following operations in the voxel model control method by executing the computer executable instructions:
[0098] A voxel model is generated based on a target model; wherein the shape of the voxel model matches the shape of the target model; the voxel model includes a plurality of voxel units; the voxel units are preset with corresponding model positions on the target model; hair follicles are created at the model positions corresponding to the voxel units, and a constraint relationship between the hair follicles and the voxel units is set; wherein the hair follicles are attached to the model positions of the target model; the target model is controlled to change dynamically, so as to control the change of the voxel units based on the constraint relationship through the hair follicles, so that the dynamic change of the voxel model matches the dynamic change of the target model.
[0099] Generate a bounding box that surrounds the target model, and generate multiple standard voxels in the bounding box; determine the edge voxels located on the specified plane of the bounding box from the multiple standard voxels, and determine the starting point of the ray based on the edge voxels; emit rays from the starting point of the ray into the bounding box, and obtain the collision point where the ray collides with the target model on the target model; based on the collision point, generate voxel units that constitute the voxel model.
[0100] Use the preset standard voxels to uniformly fill the bounding box until the bounding box is filled with standard voxels.
[0101] Record the standard position of the standard voxel in the bounding box.
[0102] The above-mentioned designated planes include three planes, and any two of the three planes are connected to each other and are perpendicular to each other.
[0103] The target voxel position on the edge voxel that is closest to the specified plane is determined as the starting point of the ray.
[0104] From the standard voxels in the bounding box, the target standard voxel closest to the collision point is obtained, and the target standard voxel is used as the voxel unit constituting the voxel model.
[0105] The texture data of the target model is obtained; the rendering parameters of the model position are obtained from the texture data through the hair follicles; and the voxel units corresponding to the hair follicles are rendered using the rendering parameters.
[0106] The collision point corresponding to the voxel unit is obtained, and the mapping coordinates corresponding to the collision point are set as the mapping coordinates of the hair follicle; based on the mapping coordinates of the hair follicle, the rendering parameters are obtained from the mapping data.
[0107] In the above method, a voxel model including multiple voxel units is generated according to the target model, hair follicles are created at the model position of the target model corresponding to the voxel units, and a constraint relationship is set between the hair follicles and the voxel units. When the target model changes dynamically, the hair follicles at the model position control the voxel units to change dynamically at the same time through the constraint relationship. This method enables the voxel model to follow the dynamic changes of the target model through the hair follicles. The operation is simple and convenient, which improves the production efficiency of voxel animation.
[0108] The computer program product of the voxel model control method, device and electronic device provided in the embodiments of the present invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be found in the method embodiments and will not be repeated here.
[0109] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0110] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, and it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0111] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0112] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0113] Finally, it should be noted that the above embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above embodiments, those skilled in the art should understand that any person skilled in the art can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A voxel model control method, characterized in that: The method comprises: Generate a voxel model based on the target model; wherein the shape of the voxel model matches the shape of the target model; the voxel model includes a plurality of voxel units; the voxel units are preset with corresponding model positions on the target model; Creating a hair follicle at a model position corresponding to the voxel unit, and setting a constraint relationship between the hair follicle and the voxel unit; wherein the hair follicle is attached to the model position of the target model; The target model is controlled to change dynamically, so as to control the change of the voxel unit based on the constraint relationship through the hair follicle, so that the dynamic change of the voxel model matches the dynamic change of the target model.
2. The method according to claim 1, characterized in that The steps of generating a voxel model based on the target model include: generating a bounding box surrounding the target model, and generating a plurality of standard voxels within the bounding box; Determine, from the plurality of standard voxels, an edge voxel located on a specified plane of the bounding box, and determine a ray starting point based on the edge voxel; Emitting a ray from the starting point of the ray into the interior of the bounding box, and obtaining a collision point on the target model where the ray collides with the target model; Based on the collision points, voxel units constituting the voxel model are generated.
3. The method according to claim 2, characterized in that The step of generating a plurality of standard voxels in the bounding box includes: uniformly filling the bounding box with preset standard voxels until the bounding box is fully filled with the standard voxels.
4. The method according to claim 2, characterized in that After the step of generating a plurality of standard voxels within the bounding box, the method further comprises: recording standard positions of the standard voxels within the bounding box.
5. The method according to claim 2, characterized in that The designated planes include three planes, and any two of the three planes are connected to each other and perpendicular to each other.
6. The method according to claim 2, characterized in that The step of determining the starting point of the ray based on the edge voxel includes: determining the target voxel position on the edge voxel that is closest to the designated plane as the starting point of the ray.
7. The method according to claim 2, characterized in that The step of generating voxel units constituting the voxel model based on the collision point comprises: A target standard voxel closest to the collision point is obtained from the standard voxels within the bounding box, and the target standard voxel is used as a voxel unit constituting the voxel model.
8. The method according to claim 1, characterized in that After the step of creating a hair follicle at the model position corresponding to the voxel unit, the method further includes: Obtaining texture data of the target model; Obtaining rendering parameters of the model position from the mapping data through the hair follicles; The voxel unit corresponding to the hair follicle is rendered using the rendering parameters.
9. The method according to claim 1, characterized in that The step of obtaining the rendering parameters of the model position from the mapping data through the hair follicles includes: Obtaining a collision point corresponding to the voxel unit, and setting the mapping coordinates corresponding to the collision point as the mapping coordinates of the hair follicle; Rendering parameters are obtained from the mapping data based on the mapping coordinates of the hair follicles.
10. A voxel model control device, characterized in that: The device comprises: A voxel model generation module is configured to generate a voxel model based on a target model; wherein the shape of the voxel model matches the shape of the target model; the voxel model includes a plurality of voxel units; and the voxel units are preset with corresponding model positions on the target model; a constraint relationship setting module, configured to create a hair follicle at a model position corresponding to the voxel unit and set a constraint relationship between the hair follicle and the voxel unit; wherein the hair follicle is attached to the model position of the target model; A dynamic change control module is used to control the target model to change dynamically, so as to control the change of the voxel unit based on the constraint relationship through the hair follicle, so that the dynamic change of the voxel model matches the dynamic change of the target model.
11. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the voxel model control method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the voxel model control method according to any one of claims 1 to 9.